package com.ship.dispatch.service.fob.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ship.common.core.utils.StringUtils;
import com.ship.common.core.web.domain.JsonResult;
import com.ship.common.business.service.impl.BaseServiceImpl;
import com.ship.common.core.utils.DateUtil;
import com.ship.dispatch.bean.ConShipping;
import com.ship.dispatch.bean.SpDispatchSchemeDetail;
import com.ship.dispatch.bean.SpDispatchSchemeExecute;
import com.ship.dispatch.bean.SpFobSublease;
import com.ship.dispatch.bean.fob.*;
import com.ship.dispatch.bpm.utils.CalculateDateUtil;
import com.ship.dispatch.bpm.utils.JsonUtils;
import com.ship.dispatch.bpm.vo.dto.BGTableDto;
import com.ship.dispatch.bpm.vo.dto.CharterRateDto;
import com.ship.dispatch.mapper.fob.SpFobCzqrldlxzlMapper;
import com.ship.dispatch.mapper.fob.SpFobJsfhccbItemsMapper;
import com.ship.dispatch.service.ConShippingService;
import com.ship.dispatch.service.SpDispatchSchemeExecuteService;
import com.ship.dispatch.service.SpFobSubleaseService;
import com.ship.dispatch.service.fob.*;
import liquibase.pro.packaged.B;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.time.*;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @author yl
 * @title SpFobJsfhccbItemsServiceImpl
 * @description
 * @create 2023/12/28 0028
 */
@Service
public class SpFobJsfhccbItemsServiceImpl extends BaseServiceImpl<SpFobJsfhccbItemsMapper, SpFobJsfhccbItems> implements SpFobJsfhccbItemsService {

    @Autowired
    SpDispatchSchemeExecuteService spDispatchSchemeExecuteService;

    @Autowired
    SpFobQrxzgService spFobQrxzgService;

    @Autowired(required = false)
    SpFobCzqrldlxzlMapper spFobCzqrldlxzlMapper;
    @Autowired
    SpFobZfzzcdyfkService spFobZfzzcdyfkService;

    @Autowired
    SpFobZfxzcdyfkService spFobZfxzcdyfkService;

    @Autowired
    SpFobGmbxService spFobGmbxService;

    @Autowired(required = false)
    SpFobJsfhccbItemsMapper spFobJsfhccbItemsMapper;

    @Autowired
    SpFobFileRecordService spFobFileRecordService;
    @Autowired
    SpFobCzqrldlxzlService spFobCzqrldlxzlService;

    @Autowired
    ConShippingService conShippingService;


    @Autowired
    SpFobSubleaseDeliveryUpdateService spFobSubleaseDeliveryUpdateService;

    @Autowired
    SpFobSubleaseRedeliveryUpdateService spFobSubleaseRedeliveryUpdateService;

    @Autowired
    SpFobSubleaseService spFobSubleaseService;

    @Override
    @Transactional
    public JsonResult getBgCostInfo(Long costId,String processInstanceId,String key) {
        List<SpFobJsfhccbItems> list = this.baseMapper.selectList(new LambdaQueryWrapper<SpFobJsfhccbItems>().eq(SpFobJsfhccbItems::getJsfhccbId,costId).orderByAsc(SpFobJsfhccbItems::getOrderNo));
        if(list==null || list.size()==0){
            if("FOB005-06".equals(key)){
                initPartInfo(costId,processInstanceId,key);
            } else if("FOB006-12".equals(key)){
                initPartInfo(costId,processInstanceId,key);
            } else if("FOB007-13".equals(key)){
                initFob07PartInfo(costId,processInstanceId,key);
            } else if("FOB008-07".equals(key)){
                initFob08PartInfo(costId,processInstanceId,key);
            }else if("FOB008-15".equals(key)){
                initFob085PartInfo(costId,processInstanceId,key);
            }
            else {
                initTableInfo(costId,processInstanceId,key);
            }
            list = this.baseMapper.selectList(new LambdaQueryWrapper<SpFobJsfhccbItems>().eq(SpFobJsfhccbItems::getJsfhccbId,costId).orderByAsc(SpFobJsfhccbItems::getOrderNo));
        }
        Map<String,Object> node = null;
        if("FOB005-06".equals(key)){
            node = valPart(list,processInstanceId,key);
        }
        else if("FOB006-12".equals(key)){
            node = valPart(list,processInstanceId,key);
        }else if("FOB007-13".equals(key)){
            node = valPartFob07(list,processInstanceId,key);
        }else if("FOB008-07".equals(key)){
            node = valPartFob08(list,processInstanceId,key);
        }else if("FOB008-15".equals(key)){
            node = valPartFob085(list,processInstanceId,key);
        }
        else {
            node =  valTable(list,processInstanceId,key);
        }
        return JsonResult.success(node);
    }

    @Override
    public JsonResult saveBgCostInfo(List<SpFobJsfhccbItems> spFobJsfhccbItems) {
        for(SpFobJsfhccbItems items:spFobJsfhccbItems){
            if(items.getId()!=null){
                this.updateById(items);
            }else{
                this.save(items);
            }
        }
        return JsonResult.success();
    }

    @Override
    public JsonResult getInstructionsInfo(Long costId, String processInstanceId, String key) {
        List<SpFobJsfhccbItems> list = this.baseMapper.selectList(new LambdaQueryWrapper<SpFobJsfhccbItems>().eq(SpFobJsfhccbItems::getJsfhccbId,costId).orderByAsc(SpFobJsfhccbItems::getOrderNo));
        if(list==null || list.size()==0){
            initInstructionsTableInfo(costId,processInstanceId,key);
            list = this.baseMapper.selectList(new LambdaQueryWrapper<SpFobJsfhccbItems>().eq(SpFobJsfhccbItems::getJsfhccbId,costId).orderByAsc(SpFobJsfhccbItems::getOrderNo));
        }
        Map<String,Object> node =  valTable(list,processInstanceId,key);
        return null;
    }

    @Override
    public JsonResult getDeliveryDate(String processInstanceId, Integer type, Integer unit) {
        Date date = null;
        if(type==0){
            SpFobSubleaseDeliveryUpdate deliveryUpdate = spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
            if(unit==0){
                date = deliveryUpdate.getDeliveryDateUtc();
            }else {
                date = deliveryUpdate.getDeliveryDate();
            }
        }else {
            SpFobSubleaseRedeliveryUpdate redeliveryUpdate=  spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);
            if(unit==0){
                date = redeliveryUpdate.getRedeliveryDateUtc();
            }else {
                date = redeliveryUpdate.getRedeliveryDate();
            }
        }
        if(date!=null){
            return JsonResult.success(DateUtil.date2Str(date,"yyyy-MM-dd HH:mm:s"));
        }else{
            return JsonResult.success("");
        }
    }

    private void initInstructionsTableInfo(Long costId, String processInstanceId, String key) {
        SpDispatchSchemeExecute execute = spDispatchSchemeExecuteService.getExceuteByInstanceId(processInstanceId);
        Map<String,Object> node = new HashMap<>();


    }

    public List<SpFobJsfhccbItems> part1(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part1");
        A1.setJsfhccbId(costId);
        A1.setA1("交船日期");
        A1.setA1Type("text");
        A1.setA2Type("date");
        // 实际装载时间
        String startDate = null;
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc()!=null){
            startDate = DateUtil.date2Str(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A1.setA2(startDate);
        }
        A1.setA3Type("select");
        A1.setA3("UTC");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part1");
        A2.setJsfhccbId(costId);
        A2.setA1("还船日期");
        A2.setA1Type("text");
        A2.setA2Type("date");
        String endDate = null;
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate =  spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc()!=null){
            endDate = DateUtil.date2Str(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A2.setA2(endDate);
        }
        A2.setA3Type("select");
        A2.setA3("UTC");
        A2.setA4Type("input");
        A2.setA4("见交船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part1");
        A3.setJsfhccbId(costId);
        A3.setA1("租金");
        A3.setA1Type("text");
        A3.setA2Type("input");

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        String rent = null;
        if(conShipping!=null){
            if(spFobSubleaseDeliveryUpdate.getDeliveryDate()!=null && StringUtils.isNotEmpty(conShipping.getRentTimeSlot())){
                CharterRateDto charterRateDto = getRate(conShipping,spFobSubleaseDeliveryUpdate.getDeliveryDate());
                if(charterRateDto!=null && charterRateDto.getRentParagraph()!=null){
                    rent = charterRateDto.getRentParagraph();
                }else {
                    rent = conShipping.getRent()+"";
                }
            }else{
                rent = conShipping.getRent()+"";
            }
            A3.setA2(rent);
        }
        A3.setA3Type("input");
        A3.setA3("USD");
        A3.setA4Type("input");
        A3.setA4("见租船合同TCP");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part1");
        A4.setJsfhccbId(costId);
        A4.setA1("租船天数");
        A4.setA1Type("text");
        A4.setA2Type("input");
        float nums = 0;
        if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
            // 时间差
            nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A4.setA2(nums+"");
        }
        A4.setA3("天");
        A4.setA3Type("text");
        A4.setA4("租船天数=还船日期-交船日期");
        A4.setA4Type("text");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part1");
        A5.setJsfhccbId(costId);
        A5.setA1("租金结算");
        A5.setA1Type("text");
        A5.setA2Type("input");
        if(nums!=0 && rent!=null){
            // 时间差
            double re = nums*Float.parseFloat(rent);
            A5.setA2(re+"");
        }
        A5.setA3("USD");
        A5.setA3Type("text");
        A5.setA4("租金=租船天数*租金");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A5);
        return tables1;
    }

    @Autowired
    SpFobSubleaseDeliveryJsService spFobSubleaseDeliveryJsService;
    public List<SpFobJsfhccbItems> part11(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part1");
        A1.setJsfhccbId(costId);
        A1.setA1("交船日期");
        A1.setA1Type("text");
        A1.setA2Type("date");
        // 实际装载时间
        String startDate = null;
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc()!=null){
            startDate = DateUtil.date2Str(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A1.setA2(startDate);
        }
        A1.setA3Type("select");
        A1.setA3("UTC");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part1");
        A2.setJsfhccbId(costId);
        A2.setA1("还船日期");
        A2.setA1Type("text");
        A2.setA2Type("date");
        String endDate = null;
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate =  spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc()!=null){
            endDate = DateUtil.date2Str(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A2.setA2(endDate);
        }
        A2.setA3Type("select");
        A2.setA3("UTC");
        A2.setA4Type("input");
        A2.setA4("见还船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part1");
        A3.setJsfhccbId(costId);
        A3.setA1("租金");
        A3.setA1Type("text");
        A3.setA2Type("input");

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        String rent = null;
        if(conShipping!=null){
            A3.setA2(conShipping.getRent()+"");
        }
        A3.setA3Type("input");
        A3.setA3("USD");
        A3.setA4Type("input");
        A3.setA4("见租船合同TCP");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A3);

        SpFobSubleaseDeliveryJs spFobSubleaseDeliveryJs= spFobSubleaseDeliveryJsService.findData(processInstanceId);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part1");
        A4.setJsfhccbId(costId);
        A4.setA1("交船结算时所付租金");
        A4.setA1Type("text");
        A4.setA2Type("input");
        if(spFobSubleaseDeliveryJs!=null){
            A4.setA2(spFobSubleaseDeliveryJs.getBalance());
        }
        A4.setA3("USD");
        A4.setA3Type("text");
        A4.setA4("");
        A4.setA4Type("text");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part1");
        A5.setJsfhccbId(costId);
        A5.setA1("租船天数");
        A5.setA1Type("text");
        A5.setA2Type("input");
        float nums = 0;
        if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
            // 时间差
            nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A5.setA2(nums+"");
        }
        A5.setA3("天");
        A5.setA3Type("text");
        A5.setA4("租船天数=还船日期-交船日期");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part1");
        A6.setJsfhccbId(costId);
        A6.setA1("租金结算");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(nums!=0 && rent!=null){
            // 时间差
            double re = nums*Float.parseFloat(rent);
            A6.setA2(re+"");
        }
        A6.setA3("USD");
        A6.setA3Type("text");
        A6.setA4("租金=租船天数*租金");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A6);
        return tables1;
    }

    @Autowired
    @Lazy
    SpFobSubleaseRentCompleteService spFobSubleaseRentCompleteService;

    public List<SpFobJsfhccbItems> part31(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part1");
        A1.setJsfhccbId(costId);
        A1.setA1("交船日期");
        A1.setA1Type("text");
        A1.setA2Type("date");
        // 实际装载时间
        String startDate = null;
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc()!=null){
            startDate = DateUtil.date2Str(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A1.setA2(startDate);
        }
        A1.setA3Type("select");
        A1.setA3("UTC");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part1");
        A2.setJsfhccbId(costId);
        A2.setA1("还船日期");
        A2.setA1Type("text");
        A2.setA2Type("date");
        String endDate = null;
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate =  spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc()!=null){
            endDate = DateUtil.date2Str(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A1.setA2(endDate);
        }
        A2.setA3Type("input");
        A2.setA3("UTC");
        A2.setA4Type("input");
        A2.setA4("见交船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part1");
        A3.setJsfhccbId(costId);
        A3.setA1("租金");
        A3.setA1Type("text");
        A3.setA2Type("input");

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        String rent = null;
        if(conShipping!=null){
            rent = conShipping.getRent()+"";
            A3.setA2(rent);
        }
        A3.setA3Type("input");
        A3.setA3("USD/EUR");
        A3.setA4Type("input");
        A3.setA4("见租船合同TCP");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A3);

        String result = spFobSubleaseRentCompleteService.findData(processInstanceId);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part1");
        A4.setJsfhccbId(costId);
        A4.setA1("收取租金");
        A4.setA1Type("text");
        A4.setA2Type("input");
        if(result!=null){
            A4.setA2(result);
        }
        A4.setA3("USD/EUR");
        A4.setA3Type("text");
        A4.setA4("");
        A4.setA4Type("text");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part1");
        A5.setJsfhccbId(costId);
        A5.setA1("租船天数");
        A5.setA1Type("text");
        A5.setA2Type("input");
        float nums = 0;
        if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
            // 时间差
            nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A5.setA2(nums+"");
        }
        A5.setA3("天");
        A5.setA3Type("text");
        A5.setA4("租船天数=还船日期-交船日期");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part1");
        A6.setJsfhccbId(costId);
        A6.setA1("租金结算");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(nums!=0 && rent!=null){
            // 时间差
            double re = nums*Float.parseFloat(rent)-Double.parseDouble(result);
            A6.setA2(re+"");
        }
        A6.setA3("USD");
        A6.setA3Type("text");
        A6.setA4("租金=租船天数*租金");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 1（运费=交船还船天数差×租金）");
        tables1.add(A6);
        return tables1;
    }

    public List<SpFobJsfhccbItems> part32(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part2");
        A1.setJsfhccbId(costId);
        A1.setA1("航距");
        A1.setA1Type("text");
        A1.setA2Type("input");
        A1.setA3Type("text");
        A1.setA3("海里");
        A1.setA4Type("input");
        A1.setA4("Dataloy查询得出");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part2");
        A2.setJsfhccbId(costId);
        A2.setA1("航速");
        A2.setA1Type("text");
        A2.setA2Type("input");
        A2.setA2("16");
        A2.setA3Type("text");
        A2.setA3("节");
        A2.setA4Type("input");
        A2.setA4("TCP约定的还船费计算速度");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part2");
        A3.setJsfhccbId(costId);
        A3.setA1("航行天数");
        A3.setA1Type("text");
        A3.setA2Type("input");

        A3.setA3Type("text");
        A3.setA3("天");
        A3.setA4Type("input");
        A3.setA4("航行天数=航距/航速/24");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part2");
        A4.setJsfhccbId(costId);
        A4.setA1("还船费租金部分");
        A4.setA1Type("text");
        A4.setA2Type("input");
        A4.setA3("USD");
        A4.setA3Type("text");
        A4.setA4("租金部分=租金*还船费的航行天数");
        A4.setA4Type("text");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A4);
        return tables1;
    }

    public List<SpFobJsfhccbItems> part33(Long costId,String processInstanceId,SpFobSublease execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        ConShipping conShipping = conShippingService.getById(execute.getConId());

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part3");
        A5.setJsfhccbId(costId);
        A5.setA1("油耗");
        A5.setA1Type("text");
        A5.setA2Type("input");
        if(conShipping!=null){
            A5.setA2(conShipping.getShipSpeedForRedeliveryFee()+"");
        }
        A5.setA3("FOE t/day");
        A5.setA3Type("text");
        A5.setA4("从船舶Form B查询得出，对应16节空载的油耗");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(1);
        A5.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part3");
        A6.setJsfhccbId(costId);
        A6.setA1("燃油消耗");
        A6.setA1Type("text");
        A6.setA2Type("input");
        A6.setA3("FOE t");
        A6.setA3Type("text");
        A6.setA4("燃油消耗=每日油耗*还船费计算的航行天数");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(2);
        A6.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part3");
        A7.setJsfhccbId(costId);
        A7.setA1("FOE");
        A7.setA1Type("text");
        A7.setA2Type("input");

        if(conShipping!=null){
            A7.setA2(conShipping.getFoe()+"");
        }
        A7.setA3("FOE t");
        A7.setA3Type("text");
        A7.setA4("燃油消耗=每日油耗*还船费计算的航行天数");
        A7.setA4Type("text");
        A7.setA5Type("upload");
        A7.setOrderNo(3);
        A7.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part3");
        A8.setJsfhccbId(costId);
        A8.setA1("LNG消耗");
        A8.setA1Type("text");
        A8.setA2Type("input");
        A8.setA3("m³");
        A8.setA3Type("text");
        A8.setA4("LNG消耗=燃油消耗/FOE");
        A8.setA4Type("text");
        A8.setA5Type("upload");
        A8.setOrderNo(4);
        A8.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part3");
        A9.setJsfhccbId(costId);
        A9.setA1("所载LNG热值");
        A9.setA1Type("text");
        A9.setA2Type("input");
        A9.setA3("MMBtu");
        A9.setA3Type("text");
        A9.setA4Type("text");
        A9.setA5Type("upload");
        A9.setOrderNo(5);
        A9.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part3");
        A10.setJsfhccbId(costId);
        A10.setA1("所载LNG体积");
        A10.setA1Type("text");
        A10.setA2Type("input");
        A10.setA3("m³");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA5Type("upload");
        A10.setOrderNo(6);
        A10.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part3");
        A11.setJsfhccbId(costId);
        A11.setA1("FC");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("MMBtu/m³");
        A11.setA3Type("text");
        A11.setA4Type("text");
        A11.setA4("FC=所载LNG热值/所载LNG体积");
        A11.setA5Type("upload");
        A11.setOrderNo(7);
        A11.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A11);

        SpFobJsfhccbItems A12 = new SpFobJsfhccbItems();
        A12.setTableId("Part3");
        A12.setJsfhccbId(costId);
        A12.setA1("LNG价格（DES）");
        A12.setA1Type("text");
        A12.setA2Type("input");
        A12.setA3("USD/MMbtu");
        A12.setA3Type("text");
        A12.setA4Type("text");
        A12.setA5Type("upload");
        A12.setOrderNo(8);
        A12.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A12);

        SpFobJsfhccbItems A13 = new SpFobJsfhccbItems();
        A13.setTableId("Part3");
        A13.setJsfhccbId(costId);
        A13.setA1("2.2还船费燃料部分");
        A13.setA1Type("text");
        A13.setA2Type("input");
        A13.setA3("USD");
        A13.setA3Type("text");
        A13.setA4Type("text");
        A13.setA4("2.2 燃油部分=LNG消耗（m³）* FC*LNG 价格");
        A13.setA5Type("upload");
        A13.setOrderNo(9);
        A13.setTableName("Part 3（还船费燃油部分）");
        tables1.add(A13);

        SpFobJsfhccbItems A14 = new SpFobJsfhccbItems();
        A14.setTableId("Part2");
        A14.setJsfhccbId(costId);
        A14.setA1("还船费结算");
        A14.setA1Type("text");
        A14.setA2Type("input");
        A14.setA3("USD");
        A14.setA3Type("text");
        A14.setA4Type("text");
        A14.setA4("还船费结算=2.1还船费租金部分+2.2还船费燃料部分");
        A14.setA5Type("upload");
        A14.setOrderNo(10);
        A14.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A14);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part34(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part4");
        A1.setJsfhccbId(costId);
        A1.setA1("交船时LSMGO");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate!=null){
            A1.setA2(spFobSubleaseDeliveryUpdate.getLsmgo());
        }

        A1.setA3Type("text");
        A1.setA3("T");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A1);
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part4");
        A2.setJsfhccbId(costId);
        A2.setA1("还船时LSMGO");
        A2.setA1Type("text");
        A2.setA2Type("input");
        if(spFobSubleaseRedeliveryUpdate!=null){
            A1.setA2(spFobSubleaseRedeliveryUpdate.getLsmgo());
        }
        A2.setA3Type("text");
        A2.setA3("T");
        A2.setA4Type("input");
        A2.setA4("见还船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part4");
        A3.setJsfhccbId(costId);
        A3.setA1("LSMGO部分1");
        A3.setA1Type("text");
        A3.setA2Type("input");
        if(A1.getA2()!=null && A2.getA2()!=null){
            BigDecimal num = new BigDecimal(A1.getA2()).subtract(new BigDecimal(A2.getA2()));
            num =  num.setScale(4, BigDecimal.ROUND_DOWN);
            A3.setA2(num+"");
        }
        A3.setA3Type("text");
        A3.setA3("T");
        A3.setA4Type("input");
        A3.setA4("LSMGO 部分 1=交船时LSMGO-还船时LSMGO");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part4");
        A4.setJsfhccbId(costId);
        A4.setA1("LSMGO价格1");
        A4.setA1Type("text");
        A4.setA2Type("input");
        A4.setA3("USD/T");
        A4.setA3Type("text");
        A4.setA4("");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part4");
        A5.setJsfhccbId(costId);
        A5.setA1("3.1LSMGO结算");
        A5.setA1Type("text");
        A5.setA2Type("input");
        A5.setA3("USD");
        A5.setA3Type("text");
        A5.setA4("3.1LSMGO结算=LSMGO 部分 1*LSMGO 价格 1");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part4");
        A6.setJsfhccbId(costId);
        A6.setA1("交船时 VLSFO");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(spFobSubleaseDeliveryUpdate!=null){
            A6.setA2(spFobSubleaseDeliveryUpdate.getVisfo());
        }
        A6.setA3("T");
        A6.setA3Type("text");
        A6.setA4("见交船通知");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part4");
        A7.setJsfhccbId(costId);
        A7.setA1("还船时VLSFO");
        A7.setA1Type("text");
        A7.setA2Type("input");
        if(spFobSubleaseRedeliveryUpdate!=null){
            A7.setA2(spFobSubleaseRedeliveryUpdate.getVisfo());
        }
        A7.setA3("T");
        A7.setA3Type("text");
        A7.setA4("见还船通知");
        A7.setA4Type("input");
        A7.setA5Type("upload");
        A7.setOrderNo(7);
        A7.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part4");
        A8.setJsfhccbId(costId);
        A8.setA1("VLSFO部分1");
        A8.setA1Type("text");
        A8.setA2Type("input");
        if(A6.getA2()!=null && A7.getA2()!=null){
            BigDecimal num = new BigDecimal(A6.getA2()).subtract(new BigDecimal(A7.getA2()));
            A8.setA2(num+"");
        }
        A8.setA3("T");
        A8.setA3Type("text");
        A8.setA4("VLSFO 部分 1=交船时VLSFO-还船时VLSFO");
        A8.setA4Type("input");
        A8.setA5Type("upload");
        A8.setOrderNo(8);
        A8.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part4");
        A9.setJsfhccbId(costId);
        A9.setA1("VLSFO价格1");
        A9.setA1Type("text");
        A9.setA2Type("input");
        A9.setA3("USD/T");
        A9.setA3Type("text");
        A9.setA4Type("input");
        A9.setA5Type("upload");
        A9.setOrderNo(9);
        A9.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part4");
        A10.setJsfhccbId(costId);
        A10.setA1("3.2VLSFO结算");
        A10.setA1Type("text");
        A10.setA2Type("input");
        A10.setA3("USD");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA4("3.2 VLSFO结算=VLSFO 部分 1*VLSFO 价格 1");
        A10.setA5Type("upload");
        A10.setOrderNo(10);
        A10.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part4");
        A11.setJsfhccbId(costId);
        A11.setA1("燃油部分结算");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("USD");
        A11.setA3Type("text");
        A11.setA4Type("input");
        A11.setA4("燃油部分结算=3.1LSMGO结算+3.2 VLSFO结算");
        A11.setA5Type("upload");
        A11.setOrderNo(11);
        A11.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A11);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part35(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part5");
        A1.setJsfhccbId(costId);
        A1.setA1("交船LNG");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate!=null){
            A1.setA2(spFobSubleaseDeliveryUpdate.getLng());
        }
        A1.setA3Type("text");
        A1.setA3("m³");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part5");
        A2.setJsfhccbId(costId);
        A2.setA1("交船时 LNG 总价");
        A2.setA1Type("text");
        A2.setA2Type("input");
        A2.setA3Type("text");
        A2.setA3("T");
        A2.setA4Type("input");
        A2.setA4("见交船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A2);
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part5");
        A3.setJsfhccbId(costId);
        A3.setA1("还船LNG");
        A3.setA1Type("text");
        A3.setA2Type("input");
        if(spFobSubleaseRedeliveryUpdate!=null){
            A3.setA2(spFobSubleaseRedeliveryUpdate.getLng());
        }
        A3.setA3Type("text");
        A3.setA3("T");
        A3.setA4Type("input");
        A3.setA4("");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part5");
        A4.setJsfhccbId(costId);
        A4.setA1("FC2");
        A4.setA1Type("text");
        A4.setA2Type("input");
        A4.setA3("");
        A4.setA3Type("input");
        A4.setA4("");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part5");
        A5.setJsfhccbId(costId);
        A5.setA1("还船时 LNG 单价");
        A5.setA1Type("text");
        A5.setA2Type("input");
        A5.setA3("USD/MMBtu");
        A5.setA3Type("text");
        A5.setA4("");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part5");
        A6.setJsfhccbId(costId);
        A6.setA1("还船时LNG总价");
        A6.setA1Type("text");
        A6.setA2Type("input");
        A6.setA3("USD");
        A6.setA3Type("text");
        A6.setA4("还船时 LNG 总价=还船Heel*FC2*还船时 LNG 单价");
        A6.setA4Type("input");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part5");
        A7.setJsfhccbId(costId);
        A7.setA1("LNG底角结算");
        A7.setA1Type("text");
        A7.setA2Type("input");
        A7.setA3("USD");
        A7.setA3Type("text");
        A7.setA4("LNG底角结算=交船时 LNG 总价-还船时 LNG 总价");
        A7.setA4Type("input");
        A7.setA5Type("upload");
        A7.setOrderNo(7);
        A7.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A7);

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getCurrency()!=null && conShipping.getCurrency()==3){
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part5");
            A8.setJsfhccbId(costId);
            A8.setA1("合计1");
            A8.setA1Type("text");
            A8.setA2Type("input");
            A8.setA3("EUR");
            A8.setA3Type("text");
            A8.setA4("合计 1=租金结算+还船费租金部分");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
            tables1.add(A8);
            SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
            A9.setTableId("Part5");
            A9.setJsfhccbId(costId);
            A9.setA1("合计2");
            A9.setA1Type("text");
            A9.setA2Type("input");
            A9.setA3("USD");
            A9.setA3Type("text");
            A9.setA4("合计 2= 还船费燃油部分结算+燃油结算+LNG 底角结算");
            A9.setA4Type("input");
            A9.setA5Type("upload");
            A9.setOrderNo(9);
            A9.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
            tables1.add(A9);
        }else {
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part5");
            A8.setJsfhccbId(costId);
            A8.setA1("合计");
            A8.setA1Type("text");
            A8.setA2Type("input");
            A8.setA3("USD");
            A8.setA3Type("text");
            A8.setA4("合计=租金结算+还船费结算+燃油结算+LNG 底角结算");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
            tables1.add(A8);
        }
        return tables1;
    }

    public List<SpFobJsfhccbItems> part2(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part2");
        A1.setJsfhccbId(costId);
        A1.setA1("航距");
        A1.setA1Type("text");
        A1.setA2Type("input");
        A1.setA3Type("text");
        A1.setA3("海里");
        A1.setA4Type("input");
        A1.setA4("Dataloy查询得出");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part2");
        A2.setJsfhccbId(costId);
        A2.setA1("航速");
        A2.setA1Type("text");
        A2.setA2Type("input");
        A2.setA2("16");
        A2.setA3Type("text");
        A2.setA3("节");
        A2.setA4Type("input");
        A2.setA4("TCP约定的还船费计算速度");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part2");
        A3.setJsfhccbId(costId);
        A3.setA1("航行天数");
        A3.setA1Type("text");
        A3.setA2Type("input");

        A3.setA3Type("text");
        A3.setA3("天");
        A3.setA4Type("input");
        A3.setA4("航行天数=航距/航速/24");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part2");
        A4.setJsfhccbId(costId);
        A4.setA1("还船费租金部分");
        A4.setA1Type("text");
        A4.setA2Type("input");
        A4.setA3("USD");
        A4.setA3Type("text");
        A4.setA4("租金部分=租金*还船费的航行天数");
        A4.setA4Type("text");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part2");
        A5.setJsfhccbId(costId);
        A5.setA1("油耗");
        A5.setA1Type("text");
        A5.setA2Type("input");
        A5.setA3("FOE t/day");
        A5.setA3Type("text");
        A5.setA4("从船舶Form B查询得出，对应16节空载的油耗");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part2");
        A6.setJsfhccbId(costId);
        A6.setA1("燃油消耗");
        A6.setA1Type("text");
        A6.setA2Type("input");
        A6.setA3("FOE t");
        A6.setA3Type("text");
        A6.setA4("燃油消耗=每日油耗*还船费计算的航行天数");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part2");
        A7.setJsfhccbId(costId);
        A7.setA1("FOE");
        A7.setA1Type("text");
        A7.setA2Type("input");

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping!=null){
            A7.setA2(conShipping.getFoe()+"");
        }
        A7.setA3("FOE t");
        A7.setA3Type("text");
        A7.setA4("燃油消耗=每日油耗*还船费计算的航行天数");
        A7.setA4Type("text");
        A7.setA5Type("upload");
        A7.setOrderNo(7);
        A7.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part2");
        A8.setJsfhccbId(costId);
        A8.setA1("LNG消耗");
        A8.setA1Type("text");
        A8.setA2Type("input");
        A8.setA3("m³");
        A8.setA3Type("text");
        A8.setA4("LNG消耗=燃油消耗/FOE");
        A8.setA4Type("text");
        A8.setA5Type("upload");
        A8.setOrderNo(8);
        A8.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part2");
        A9.setJsfhccbId(costId);
        A9.setA1("所载LNG热值");
        A9.setA1Type("text");
        A9.setA2Type("input");
        A9.setA3("MMBtu");
        A9.setA3Type("text");
        A9.setA4Type("text");
        A9.setA5Type("upload");
        A9.setOrderNo(9);
        A9.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part2");
        A10.setJsfhccbId(costId);
        A10.setA1("所载LNG体积");
        A10.setA1Type("text");
        A10.setA2Type("input");
        A10.setA3("m³");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA5Type("upload");
        A10.setOrderNo(10);
        A10.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part2");
        A11.setJsfhccbId(costId);
        A11.setA1("FC");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("MMBtu/m³");
        A11.setA3Type("text");
        A11.setA4Type("text");
        A11.setA4("FC=所载LNG热值/所载LNG体积");
        A11.setA5Type("upload");
        A11.setOrderNo(11);
        A11.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A11);

        SpFobJsfhccbItems A12 = new SpFobJsfhccbItems();
        A12.setTableId("Part2");
        A12.setJsfhccbId(costId);
        A12.setA1("LNG价格（DES）");
        A12.setA1Type("text");
        A12.setA2Type("input");
        A12.setA3("USD/MMbtu");
        A12.setA3Type("text");
        A12.setA4Type("text");
        A12.setA5Type("upload");
        A12.setOrderNo(12);
        A12.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A12);

        SpFobJsfhccbItems A13 = new SpFobJsfhccbItems();
        A13.setTableId("Part2");
        A13.setJsfhccbId(costId);
        A13.setA1("2.2还船费燃料部分");
        A13.setA1Type("text");
        A13.setA2Type("input");
        A13.setA3("USD");
        A13.setA3Type("text");
        A13.setA4Type("text");
        A13.setA4("2.2 燃油部分=LNG消耗（m³）* FC*LNG 价格");
        A13.setA5Type("upload");
        A13.setOrderNo(13);
        A13.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A13);

        SpFobJsfhccbItems A14 = new SpFobJsfhccbItems();
        A14.setTableId("Part2");
        A14.setJsfhccbId(costId);
        A14.setA1("还船费结算");
        A14.setA1Type("text");
        A14.setA2Type("input");
        A14.setA3("USD");
        A14.setA3Type("text");
        A14.setA4Type("text");
        A14.setA4("还船费结算=2.1还船费租金部分+2.2还船费燃料部分");
        A14.setA5Type("upload");
        A14.setOrderNo(14);
        A14.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        tables1.add(A14);
        return tables1;
    }

    public List<SpFobJsfhccbItems> part3(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part3");
        A1.setJsfhccbId(costId);
        A1.setA1("交船时LSMGO");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate!=null){
            A1.setA2(spFobSubleaseDeliveryUpdate.getLsmgo());
        }

        A1.setA3Type("text");
        A1.setA3("T");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A1);
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part3");
        A2.setJsfhccbId(costId);
        A2.setA1("还船时LSMGO");
        A2.setA1Type("text");
        A2.setA2Type("input");
        if(spFobSubleaseRedeliveryUpdate!=null){
            A2.setA2(spFobSubleaseRedeliveryUpdate.getLsmgo());
        }
        A2.setA3Type("text");
        A2.setA3("T");
        A2.setA4Type("input");
        A2.setA4("见还船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part3");
        A3.setJsfhccbId(costId);
        A3.setA1("LSMGO部分1");
        A3.setA1Type("text");
        A3.setA2Type("input");
        if(A1.getA2()!=null && A2.getA2()!=null){
            BigDecimal num = new BigDecimal(A1.getA2()).subtract(new BigDecimal(A2.getA2()));
            A3.setA2(num+"");
        }
        A3.setA3Type("text");
        A3.setA3("T");
        A3.setA4Type("input");
        A3.setA4("LSMGO 部分 1=交船时LSMGO-还船时LSMGO");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part3");
        A4.setJsfhccbId(costId);
        A4.setA1("LSMGO价格1");
        A4.setA1Type("text");
        A4.setA2Type("input");
        A4.setA3("USD/T");
        A4.setA3Type("text");
        A4.setA4("");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part3");
        A5.setJsfhccbId(costId);
        A5.setA1("3.1LSMGO结算");
        A5.setA1Type("text");
        A5.setA2Type("input");
        A5.setA3("USD");
        A5.setA3Type("text");
        A5.setA4("3.1LSMGO结算=LSMGO 部分 1*LSMGO 价格 1");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part3");
        A6.setJsfhccbId(costId);
        A6.setA1("交船时 VLSFO");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(spFobSubleaseDeliveryUpdate!=null){
            A6.setA2(spFobSubleaseDeliveryUpdate.getVisfo());
        }
        A6.setA3("T");
        A6.setA3Type("text");
        A6.setA4("见交船通知");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part3");
        A7.setJsfhccbId(costId);
        A7.setA1("还船时VLSFO");
        A7.setA1Type("text");
        A7.setA2Type("input");
        if(spFobSubleaseRedeliveryUpdate!=null){
            A7.setA2(spFobSubleaseRedeliveryUpdate.getVisfo());
        }
        A7.setA3("T");
        A7.setA3Type("text");
        A7.setA4("见还船通知");
        A7.setA4Type("input");
        A7.setA5Type("upload");
        A7.setOrderNo(7);
        A7.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part3");
        A8.setJsfhccbId(costId);
        A8.setA1("VLSFO部分1");
        A8.setA1Type("text");
        A8.setA2Type("input");
        if(A6.getA2()!=null && A7.getA2()!=null){
            BigDecimal num = new BigDecimal(A6.getA2()).subtract(new BigDecimal(A7.getA2()));
            A8.setA2(num+"");
        }
        A8.setA3("T");
        A8.setA3Type("text");
        A8.setA4("VLSFO 部分 1=交船时VLSFO-还船时VLSFO");
        A8.setA4Type("input");
        A8.setA5Type("upload");
        A8.setOrderNo(8);
        A8.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part3");
        A9.setJsfhccbId(costId);
        A9.setA1("VLSFO价格1");
        A9.setA1Type("text");
        A9.setA2Type("input");
        A9.setA3("USD/T");
        A9.setA3Type("text");
        A9.setA4Type("input");
        A9.setA5Type("upload");
        A9.setOrderNo(9);
        A9.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part3");
        A10.setJsfhccbId(costId);
        A10.setA1("3.2VLSFO结算");
        A10.setA1Type("text");
        A10.setA2Type("input");
        A10.setA3("USD");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA4("3.2 VLSFO结算=VLSFO 部分 1*VLSFO 价格 1");
        A10.setA5Type("upload");
        A10.setOrderNo(10);
        A10.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part3");
        A11.setJsfhccbId(costId);
        A11.setA1("燃油部分结算");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("USD");
        A11.setA3Type("text");
        A11.setA4Type("input");
        A11.setA4("燃油部分结算=3.1LSMGO结算+3.2 VLSFO结算");
        A11.setA5Type("upload");
        A11.setOrderNo(11);
        A11.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A11);
        return tables1;
    }

    public List<SpFobJsfhccbItems> part4(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part4");
        A1.setJsfhccbId(costId);
        A1.setA1("交船LNG");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate!=null){
            A1.setA2(spFobSubleaseDeliveryUpdate.getLng());
        }
        A1.setA3Type("text");
        A1.setA3("m³");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part4");
        A2.setJsfhccbId(costId);
        A2.setA1("交船时 LNG 总价");
        A2.setA1Type("text");
        A2.setA2Type("input");
        A2.setA3Type("text");
        A2.setA3("T");
        A2.setA4Type("input");
        A2.setA4("见交船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A2);
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part4");
        A3.setJsfhccbId(costId);
        A3.setA1("还船LNG");
        A3.setA1Type("text");
        A3.setA2Type("input");
        if(spFobSubleaseRedeliveryUpdate!=null){
            A3.setA2(spFobSubleaseRedeliveryUpdate.getLng());
        }
        A3.setA3Type("text");
        A3.setA3("T");
        A3.setA4Type("input");
        A3.setA4("");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part4");
        A4.setJsfhccbId(costId);
        A4.setA1("FC2");
        A4.setA1Type("text");
        A4.setA2Type("input");
        A4.setA3("");
        A4.setA3Type("input");
        A4.setA4("");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part4");
        A5.setJsfhccbId(costId);
        A5.setA1("还船时 LNG 单价");
        A5.setA1Type("text");
        A5.setA2Type("input");
        A5.setA3("USD/MMBtu");
        A5.setA3Type("text");
        A5.setA4("");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part4");
        A6.setJsfhccbId(costId);
        A6.setA1("还船时LNG总价");
        A6.setA1Type("text");
        A6.setA2Type("input");
        A6.setA3("USD");
        A6.setA3Type("text");
        A6.setA4("还船时 LNG 总价=还船Heel*FC2*还船时 LNG 单价");
        A6.setA4Type("input");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part4");
        A7.setJsfhccbId(costId);
        A7.setA1("LNG底角结算");
        A7.setA1Type("text");
        A7.setA2Type("input");
        A7.setA3("USD");
        A7.setA3Type("text");
        A7.setA4("LNG底角结算=交船时 LNG 总价-还船时 LNG 总价");
        A7.setA4Type("input");
        A7.setA5Type("upload");
        A7.setOrderNo(7);
        A7.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        tables1.add(A7);

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getCurrency()!=null && conShipping.getCurrency()==3){
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part4");
            A8.setJsfhccbId(costId);
            A8.setA1("合计1");
            A8.setA1Type("text");
            A8.setA2Type("number");
            A8.setA3("EUR");
            A8.setA3Type("text");
            A8.setA4("合计 1=租金结算+还船费租金部分");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
            tables1.add(A8);
            SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
            A9.setTableId("Part4");
            A9.setJsfhccbId(costId);
            A9.setA1("合计2");
            A9.setA1Type("text");
            A9.setA2Type("number");
            A9.setA3("USD");
            A9.setA3Type("text");
            A9.setA4("合计 2= 还船费燃油部分-燃油结算-LNG 底角结算 ");
            A9.setA4Type("input");
            A9.setA5Type("upload");
            A9.setOrderNo(9);
            A9.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
            tables1.add(A9);
        }else {
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part4");
            A8.setJsfhccbId(costId);
            A8.setA1("合计");
            A8.setA1Type("text");
            A8.setA2Type("number");
            A8.setA3("USD");
            A8.setA3Type("text");
            A8.setA4("合计=租金结算+还船费结算+燃油部分结算+LNG 底角结算");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
            tables1.add(A8);
        }
        return tables1;
    }

    public CharterRateDto getRate(ConShipping conShipping,Date date1){
        CharterRateDto rent = null;
        String json = conShipping.getRentTimeSlot();
        JSONArray res = JSON.parseArray(json);
        List<CharterRateDto> charterRateDtos = res.toJavaList(CharterRateDto.class);
        for(CharterRateDto dto:charterRateDtos) {
            if(date1.compareTo(dto.getRentDateBegin())>=0 && date1.compareTo(dto.getRentDateEnd())<0){
                rent = dto;
                break;
            }
        }
        return rent;
    }

    public Map<String,Object> valTable(List<SpFobJsfhccbItems> list,String processInstanceId,String key){
        SpDispatchSchemeExecute execute = spDispatchSchemeExecuteService.getExceuteByInstanceId(processInstanceId);
        Map<String,Object> node = new HashMap<>();
        List<SpFobJsfhccbItems> tables1 = list.stream().filter(item->item.getTableId().equals("CharterCost")).collect(Collectors.toList());
        tables1 = bingTableUploadRecord(tables1);
        List<SpFobJsfhccbItems> tables2 = list.stream().filter(item->item.getTableId().equals("ShippingAgencyCost")).collect(Collectors.toList());
        tables2 = bingTableUploadRecord(tables2);
        List<SpFobJsfhccbItems> tables3 = list.stream().filter(item->item.getTableId().equals("Insurance")).collect(Collectors.toList());
        tables3 = bingTableUploadRecord(tables3);
        List<SpFobJsfhccbItems> tables4 = list.stream().filter(item->item.getTableId().equals("LSMGO")).collect(Collectors.toList());
        tables4 = bingTableUploadRecord(tables4);
        List<SpFobJsfhccbItems> tables5 = list.stream().filter(item->item.getTableId().equals("VLSFO")).collect(Collectors.toList());
        tables5 = bingTableUploadRecord(tables5);
        List<SpFobJsfhccbItems> tables6 = list.stream().filter(item->item.getTableId().equals("PositioningFee")).collect(Collectors.toList());
        tables6 = bingTableUploadRecord(tables6);
        List<SpFobJsfhccbItems> tables7 = list.stream().filter(item->item.getTableId().equals("BallastBonus")).collect(Collectors.toList());
        tables7 = bingTableUploadRecord(tables7);
        List<SpFobJsfhccbItems> tables8 = list.stream().filter(item->item.getTableId().equals("BOG")).collect(Collectors.toList());
        tables8 = bingTableUploadRecord(tables8);
        List<BGTableDto> bgTableDtos = new ArrayList<>();
        BGTableDto dto = new BGTableDto();
        dto.setTableId("CharterCost");
        dto.setTableName("Charter Cost");
        dto.setTables(tables1);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("ShippingAgencyCost");
        dto.setTableName("Shipping agency cost");
        dto.setTables(tables2);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Insurance");
        dto.setTableName("Insurance");
        dto.setTables(tables3);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("LSMGO");
        dto.setTableName("LSMGO");
        dto.setTables(tables4);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("VLSFO");
        dto.setTableName("VLSFO");
        dto.setTables(tables5);
        bgTableDtos.add(dto);


        dto = new BGTableDto();
        dto.setTableId("PositioningFee");
        dto.setTableName("Positioning fee");
        dto.setTables(tables6);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("BallastBonus");
        dto.setTableName("Ballast Bonus");
        dto.setTables(tables7);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("BOG");
        dto.setTableName("BOG");
        dto.setTables(tables8);
        bgTableDtos.add(dto);

        String endDate = null;
        if("FOB001-14".equals(key)){ //计算往返航次运费成本
            SpFobQrxzg data = spFobQrxzgService.findData(processInstanceId);
            if(data!=null && data.getExpectedUnloadingPort()!=null){
                endDate = data.getExpectedUnloadingPort();
            }
        }
        else if("FOB004-14".equals(key)){
            if(execute.getExpectedUnloadingWindow()!=null){
                endDate = CalculateDateUtil.pasrseDate(execute.getExpectedUnloadingWindow());
            }
        }
        else if("FOB001-27".equals(key) || "FOB004-27".equals(key)) { //更新往返航次运费成本
            if(null != execute && execute.getRealityUnloadingDate()!=null){
                endDate = DateUtil.date2Str(execute.getRealityUnloadingDate(),"yyyy-MM-dd HH:mm:ss");
                //endDate = spFobSyzlxzwj.getUnloadDate().toString();
            }
        }
        String time = "";
        if(execute != null && execute.getRealityLoadingDate() != null){
            time = CalculateDateUtil.pasrseDate(execute.getRealityLoadingDate())+"--";
        }
        if(endDate!=null){
            time =time +endDate;
        }
        if (execute != null) {
            node.put("shipName", execute.getShipName());
        }
        node.put("time",time);
        node.put("data",bgTableDtos);

        if (null != execute){
            // 获取上一航次信息
            SpDispatchSchemeExecute upExecute = spDispatchSchemeExecuteService.getOne(new LambdaQueryWrapper<SpDispatchSchemeExecute>().eq(SpDispatchSchemeExecute::getShipName,execute.getShipName())
                    .lt(SpDispatchSchemeExecute::getExpectedLoadingDate,execute.getExpectedLoadingDate()).orderByDesc(SpDispatchSchemeExecute::getExpectedLoadingDate).last("limit 1"));
            SpFobCzqrldlxzl  spFobCzqrldlxzl =null;
            if(upExecute!=null){
                spFobCzqrldlxzl =  spFobCzqrldlxzlService.findFormData(upExecute.getProcessInstanceId());
            }
            if(spFobCzqrldlxzl!=null){
                node.put("reserveAmount",spFobCzqrldlxzl.getReserveAmount());
            }else{
                node.put("reserveAmount","");
            }
        }
       /* tables1.addAll(tables2);
        tables1.addAll(tables3);
        tables1.addAll(tables4);
        tables1.addAll(tables5);
        tables1.addAll(tables6);
        tables1.addAll(tables7);
        tables1.addAll(tables8);

        node.put("tables",tables1);
      *//*  node.put("CharterCost",JsonUtils.objectToJson(tables1));
        node.put("ShippingAgencyCost",JsonUtils.objectToJson(tables2));
        node.put("Insurance",JsonUtils.objectToJson(tables3));
        node.put("LSMGO",JsonUtils.objectToJson(tables4));
        node.put("VLSFO",JsonUtils.objectToJson(tables5));
        node.put("PositioningFee",JsonUtils.objectToJson(tables6));
        node.put("BallastBonus",JsonUtils.objectToJson(tables7));
        node.put("BOG",JsonUtils.objectToJson(tables8));*/
        return node;
    }

    public Map<String,Object> valPart(List<SpFobJsfhccbItems> list,String processInstanceId,String key){
        SpFobSublease execute =  spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        //SpDispatchSchemeExecute execute = sp.getExceuteByInstanceId(processInstanceId);
        Map<String,Object> node = new HashMap<>();
        for(SpFobJsfhccbItems item:list){
            if(item.getTableId().equals("Part1")){

            }
        }
        List<SpFobJsfhccbItems> tables1 = list.stream().filter(item->item.getTableId().equals("Part1")).collect(Collectors.toList());
        tables1 = bingTableUploadA5Record(tables1);
        List<SpFobJsfhccbItems> tables2 = list.stream().filter(item->item.getTableId().equals("Part2")).collect(Collectors.toList());
        tables2 = bingTableUploadA5Record(tables2);
        List<SpFobJsfhccbItems> tables3 = list.stream().filter(item->item.getTableId().equals("Part3")).collect(Collectors.toList());
        tables3 = bingTableUploadA5Record(tables3);
        List<SpFobJsfhccbItems> tables4 = list.stream().filter(item->item.getTableId().equals("Part4")).collect(Collectors.toList());
        tables4 = bingTableUploadA5Record(tables4);

        List<BGTableDto> bgTableDtos = new ArrayList<>();
        BGTableDto dto = new BGTableDto();
        dto.setTableId("Part1");
        dto.setTableName("Part 1（运费=交船还船天数差×租金）");
        dto.setTables(tables1);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part2");
        dto.setTableName("Part 2（还船费=2.1租金部分+2.2燃油部分）");
        dto.setTables(tables2);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part3");
        dto.setTableName("Part 3 （燃油费用=VLSFO费用+LSMGO费用）");
        dto.setTables(tables3);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("Part4");
        dto.setTableName("Part 4（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        dto.setTables(tables4);
        bgTableDtos.add(dto);
        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getTradeBody()==1){
            node.put("currentTradeBody","国贸");
            node.put("upTradeBody","新贸");
        }else{
            node.put("currentTradeBody","新贸");
            node.put("upTradeBody","国贸");
        }
        node.put("shipName",execute.getShipName());
        node.put("shipowner",conShipping.getShipowner());
        node.put("tenant",conShipping.getTenant());
        node.put("data",bgTableDtos);
        return node;
    }

    public Map<String,Object> valPartFob07(List<SpFobJsfhccbItems> list,String processInstanceId,String key){
        SpFobSublease execute =  spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        //SpDispatchSchemeExecute execute = sp.getExceuteByInstanceId(processInstanceId);
        Map<String,Object> node = new HashMap<>();
        List<SpFobJsfhccbItems> tables1 = list.stream().filter(item->item.getTableId().equals("Part1")).collect(Collectors.toList());
        tables1 = bingTableUploadA5Record(tables1);
        List<SpFobJsfhccbItems> tables2 = list.stream().filter(item->item.getTableId().equals("Part2")).collect(Collectors.toList());
        tables2 = bingTableUploadA5Record(tables2);
        List<SpFobJsfhccbItems> tables3 = list.stream().filter(item->item.getTableId().equals("Part3")).collect(Collectors.toList());
        tables3 = bingTableUploadA5Record(tables3);
        List<SpFobJsfhccbItems> tables4 = list.stream().filter(item->item.getTableId().equals("Part4")).collect(Collectors.toList());
        tables4 = bingTableUploadA5Record(tables4);
        List<SpFobJsfhccbItems> tables5 = list.stream().filter(item->item.getTableId().equals("Part5")).collect(Collectors.toList());
        tables5 = bingTableUploadA5Record(tables5);

        List<BGTableDto> bgTableDtos = new ArrayList<>();
        BGTableDto dto = new BGTableDto();
        dto.setTableId("Part1");
        dto.setTableName("Part 1（运费=交船还船天数差×租金）");
        dto.setTables(tables1);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part2");
        dto.setTableName("Part 2（还船费租金部分）");
        dto.setTables(tables2);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part3");
        dto.setTableName("Part 3（还船费燃油部分）");
        dto.setTables(tables3);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("Part4");
        dto.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        dto.setTables(tables4);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part5");
        dto.setTableName("Part 5（LNG Heel结算=（交船Heel-还船Heel）*LNG价格");
        dto.setTables(tables5);
        bgTableDtos.add(dto);
        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getTradeBody()==1){
            node.put("currentTradeBody","国贸");
            node.put("upTradeBody","新贸");
        }else{
            node.put("currentTradeBody","新贸");
            node.put("upTradeBody","国贸");
        }
        node.put("shipowner",conShipping.getShipowner());
        node.put("shipName",execute.getShipName());
        node.put("tenant",conShipping.getTenant());
        node.put("data",bgTableDtos);
        return node;
    }

    public List<SpFobJsfhccbItems> bingTableUploadRecord( List<SpFobJsfhccbItems> table){
        for(SpFobJsfhccbItems item:table){
            if(item.getA6()!=null && item.getA6().length()>0){
                String[] ids = item.getA6().split(",");
                List<Long> resId = new ArrayList<>();
                for(String tempId:ids){
                    resId.add(Long.parseLong(tempId));
                }
                List<SpFobFileRecord> spFobFileRecordList =  spFobFileRecordService.listByIds(resId);
                item.setFiels(spFobFileRecordList);
            }
        }
        return table;
    }
    public List<SpFobJsfhccbItems> bingTableUploadA5Record( List<SpFobJsfhccbItems> table){
        for(SpFobJsfhccbItems item:table){
            if(item.getA5()!=null && item.getA5().length()>0){
                String[] ids = item.getA5().split(",");
                List<Long> resId = new ArrayList<>();
                for(String tempId:ids){
                    resId.add(Long.parseLong(tempId));
                }
                List<SpFobFileRecord> spFobFileRecordList =  spFobFileRecordService.listByIds(resId);
                item.setFiels(spFobFileRecordList);
            }
        }
        return table;
    }
    public void initFob07PartInfo(Long costId,String processInstanceId,String key){
        SpFobSublease execute = spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        List<SpFobJsfhccbItems> tables1 = part31(costId,processInstanceId,execute,key);
        this.saveBatch(tables1);
        List<SpFobJsfhccbItems> tables2 = part32(costId,processInstanceId,execute,key);
        this.saveBatch(tables2);
        List<SpFobJsfhccbItems> tables3 = part33(costId,processInstanceId,execute,key);
        this.saveBatch(tables3);
        List<SpFobJsfhccbItems> tables4 = part34(costId,processInstanceId,execute,key);
        this.saveBatch(tables4);
        List<SpFobJsfhccbItems> tables5 = part35(costId,processInstanceId,execute,key);
        this.saveBatch(tables5);
    }
    public void initPartInfo(Long costId,String processInstanceId,String key){
        SpFobSublease execute = spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        if("FOB006-12".equals(key)){
            List<SpFobJsfhccbItems> tables1 = part11(costId,processInstanceId,execute,key);
            this.saveBatch(tables1);
        }else {
            List<SpFobJsfhccbItems> tables1 = part1(costId,processInstanceId,execute,key);
            this.saveBatch(tables1);
        }
        List<SpFobJsfhccbItems> tables2 = part2(costId,processInstanceId,execute,key);
        this.saveBatch(tables2);
        List<SpFobJsfhccbItems> tables3 = part3(costId,processInstanceId,execute,key);
        this.saveBatch(tables3);
        List<SpFobJsfhccbItems> tables4 = part4(costId,processInstanceId,execute,key);
        this.saveBatch(tables4);
    }
    public void initPartInfo2(Long costId,String processInstanceId,String key){
        SpFobSublease execute = spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        List<SpFobJsfhccbItems> tables1 = part1(costId,processInstanceId,execute,key);
        this.saveBatch(tables1);
        List<SpFobJsfhccbItems> tables2 = part2(costId,processInstanceId,execute,key);
        this.saveBatch(tables2);
        List<SpFobJsfhccbItems> tables3 = part3(costId,processInstanceId,execute,key);
        this.saveBatch(tables3);
        List<SpFobJsfhccbItems> tables4 = part4(costId,processInstanceId,execute,key);
        this.saveBatch(tables4);
    }
    public Map<String,Object> initTableInfo(Long costId,String processInstanceId,String key){
        SpDispatchSchemeExecute execute = spDispatchSchemeExecuteService.getExceuteByInstanceId(processInstanceId);
        Map<String,Object> node = new HashMap<>();
        List<SpFobJsfhccbItems> tables1 = table1(costId,processInstanceId,execute,key);
        String num = addTotal("0",tables1);
        this.saveBatch(tables1);
        List<SpFobJsfhccbItems> tables2 = table2(costId,processInstanceId,execute,key);
        num = addTotal(num,tables2);
        this.saveBatch(tables2);
        List<SpFobJsfhccbItems> tables3 = table3(costId,processInstanceId,execute,key);
        this.saveBatch(tables3);
        num = addTotal(num,tables3);
        List<SpFobJsfhccbItems> tables4 = table4(costId,processInstanceId,execute,key);
        this.saveBatch(tables4);
        num = addTotal(num,tables4);
        List<SpFobJsfhccbItems> tables5 = table5(costId,processInstanceId,execute,key);
        this.saveBatch(tables5);
        num = addTotal(num,tables5);
        List<SpFobJsfhccbItems> tables6 = table6(costId,processInstanceId,execute);
        this.saveBatch(tables6);
        num = addTotal(num,tables6);
        List<SpFobJsfhccbItems> tables7 = table7(costId,processInstanceId,execute);
        this.saveBatch(tables7);
        num = addTotal(num,tables7);
        List<SpFobJsfhccbItems> tables8 = table8(costId,processInstanceId,execute,num);
        this.saveBatch(tables8);
      /*  tables1.addAll(tables2);
        tables1.addAll(tables3);
        tables1.addAll(tables4);
        tables1.addAll(tables5);
        tables1.addAll(tables6);
        tables1.addAll(tables7);
        tables1.addAll(tables8);
        node.put("shipName",execute.getShipName());
        node.put("time","");*/
       /*
        node.put("CharterCost",tables1);
        node.put("ShippingAgencyCost",tables2);
        node.put("Insurance",tables3);
        node.put("LSMGO",tables4);
        node.put("VLSFO",tables5);
        node.put("PositioningFee",tables6);
        node.put("BallastBonus",tables7);
        */
        //node.put("tables",tables1);
        return node;
    }

    public String addTotal(String num,List<SpFobJsfhccbItems> table){
        for(SpFobJsfhccbItems item:table){
            if(item.getA1()!=null && item.getA1().equals("Total") && StringUtils.isNotEmpty(item.getA2())){
                Float num1 = Float.parseFloat(num)+Float.parseFloat(item.getA2());
                num = num1+"";
                break;
            }
        }
        return num;
    }

    @Autowired
    SpFobSyzlxzwjService spFobSyzlxzwjService;
    /**
     * 第一个table Charter Cost
     * @param processInstanceId
     * @param execute
     * @return
     */
    public List<SpFobJsfhccbItems> table1(Long costId,String processInstanceId,SpDispatchSchemeExecute execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("CharterCost");
        A1.setJsfhccbId(costId);
        A1.setA1("Voyage start date");
        A1.setA1Type("text");
        A1.setA2Type("date");
        // 实际装载时间
        String startDate = null;
        if(execute.getRealityLoadingDate()!=null){
            startDate = DateUtil.date2Str(execute.getRealityLoadingDate(),"yyyy-MM-dd HH:mm:ss");
            A1.setA2(startDate);
        }
        A1.setA3Type("input");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Charter Cost");
        tables1.add(A1);
        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setA1("Voyage end date");
        A2.setTableId("CharterCost");
        A2.setJsfhccbId(costId);
        A2.setOrderNo(2);
        A2.setTableName("Charter Cost");
        A2.setA1Type("text");
        A2.setA2Type("date");
        A2.setA3Type("input");
        A2.setA4Type("input");
        A2.setA5Type("input");
        A2.setA6Type("upload");
        // 实际卸载时间

        String endDate = null;
        if("FOB001-14".equals(key)){ //计算往返航次运费成本
            SpFobQrxzg data = spFobQrxzgService.findData(processInstanceId);
            if(data!=null && data.getExpectedUnloadingPort()!=null){
                endDate = data.getExpectedUnloadingPort();
                A2.setA2(data.getExpectedUnloadingPort());
            }else {
                endDate = DateUtil.date2Str(execute.getExpectedUnloadingWindow(),"yyyy-MM-dd HH:mm:ss");
               // endDate = //CalculateDateUtil.pasrseDates(execute.getExpectedUnloadingWindow());
                A2.setA2(endDate);
            }
        }
        else if("FOB004-14".equals(key)){
            if(execute.getExpectedUnloadingWindow()!=null){
                endDate = DateUtil.date2Str(execute.getExpectedUnloadingWindow(),"yyyy-MM-dd HH:mm:ss");
            }
            A2.setA2(endDate);
        }
        else if("FOB001-27".equals(key) || "FOB004-27".equals(key)) { //更新往返航次运费成本
            if(execute.getRealityUnloadingDate()!=null){
                endDate = DateUtil.date2Str(execute.getRealityUnloadingDate(),"yyyy-MM-dd HH:mm:ss");
                //endDate = spFobSyzlxzwj.getUnloadDate().toString();
                A2.setA2(endDate);
            }
        }
        tables1.add(A2);
        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setA1("Length of voyage");
        A3.setTableId("CharterCost");
        A3.setJsfhccbId(costId);
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setA3Type("text");
        A3.setA4Type("input");
        A3.setA5Type("input");
        A3.setA6Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Charter Cost");
        // 时间差
        float nums = 0;
        if(startDate!=null && endDate!=null){
            nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A3.setA2(nums+"");
        }
        //设置单位
        A3.setA3("days");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setA1Type("text");
        A4.setTableId("CharterCost");
        A4.setA2Type("number");
        A4.setA3Type("text");
        A4.setA4Type("input");
        A4.setA5Type("input");
        A4.setA6Type("upload");
        A4.setA1("Charter rate");
        A4.setOrderNo(4);
        A4.setTableName("Charter Cost");
        A4.setJsfhccbId(costId);
        //查询船运合同组件
        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        Map<String,Object> map = spFobCzqrldlxzlMapper.selectShipCon(execute.getShipContractId());
        if(map!=null && map.containsKey("rent_time_slot") && map.get("rent_time_slot")!=null && execute.getRealityLoadingDate()!=null){ // 当前方案存在租金段
            CharterRateDto dto = getRate(map,execute.getRealityLoadingDate());
            if(dto!=null){
                A4.setA2(dto.getRentParagraph()+"");
                A4.setA3(getPriceUnitName(dto.getRentUnit())+"/day");
                A5.setA3(getPriceUnitName(dto.getRentUnit()));
            }
        }else if(map!=null && map.containsKey("rent") && map.get("rent")!=null){
            A4.setA2(map.get("rent").toString()+"");
        }
        tables1.add(A4);

        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3Type("text");
        A5.setA4Type("input");
        A5.setTableId("CharterCost");
        A5.setA5Type("input");
        A5.setA6Type("upload");
        A5.setJsfhccbId(costId);
        A5.setOrderNo(5);
        A5.setTableName("Charter Cost");
        A5.setA1("Total");
        if(A4.getA2()!=null && A3.getA2()!=null){

            Float num = Float.parseFloat(A4.getA2())*Float.parseFloat(A3.getA2());
            A5.setA2(num+"");
        }

        tables1.add(A5);
        return tables1;
    }

    /**
     * Shipping agency cost
     * @param processInstanceId
     * @param execute
     * @return
     */
    @Autowired
    SpFobWccbdlfyjsService spFobWccbdlfyjsService;
    @Autowired
    SpFobWcxzcbdlfyjsService spFobWcxzcbdlfyjsService;
    public List<SpFobJsfhccbItems> table2(Long costId,String processInstanceId,SpDispatchSchemeExecute execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        SpFobZfzzcdyfk spFobZfzzcdyfk = spFobZfzzcdyfkService.findData(processInstanceId);
        // 第二个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setA1("装载港");
        A1.setTableId("ShippingAgencyCost");
        A1.setA1Type("text");
        A1.setA2Type("number");
        A1.setJsfhccbId(costId);
        A1.setOrderNo(1);
        A1.setTableName("Shipping agency cost");
        // 金额
        BigDecimal total = new BigDecimal(0);
        if("FOB001-14".equals(key) || "FOB004-14".equals(key)){ //计算往返航次运费成本
            //SpFobSyzlzzwj spFobSyzlzzwjspFobSyzlzzwjService.findActivitiData(processInstanceId);
            if(spFobZfzzcdyfk!=null){
                A1.setA2(spFobZfzzcdyfk.getPaymentAmount()+"");
                A1.setA3("USD");
                total = total.add(spFobZfzzcdyfk.getPaymentAmount()!=null?spFobZfzzcdyfk.getPaymentAmount():new BigDecimal(0));
            }
        }
        else if("FOB001-27".equals(key) || "FOB004-27".equals(key)) { //更新往返航次运费成本

            SpFobWccbdlfyjs wccbdlfyjs  = spFobWccbdlfyjsService.findData(processInstanceId);// .find(processInstanceId);
            if(wccbdlfyjs!=null){
                A1.setA2(wccbdlfyjs.getPaymentAmount()+"");
                A1.setA3("USD");
                total = total.add(wccbdlfyjs.getPaymentAmount()!=null?wccbdlfyjs.getPaymentAmount():new BigDecimal(0));
            }
        }

        A1.setA3Type("text");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        tables1.add(A1);
        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setA1("卸载港");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setTableId("ShippingAgencyCost");
        A2.setJsfhccbId(costId);
        A2.setOrderNo(2);
        A2.setTableName("Shipping agency cost");
        // 金额
        if("FOB001-14".equals(key) || "FOB004-14".equals(key)){
            SpFobZfxzcdyfk spFobZfxzcdyfk = spFobZfxzcdyfkService.findDate(processInstanceId);

            if(spFobZfxzcdyfk!=null){
                A2.setA2(spFobZfxzcdyfk.getPaymentAmount()+"");
                A2.setA3("USD");
                total = total.add(spFobZfxzcdyfk.getPaymentAmount()!=null?spFobZfxzcdyfk.getPaymentAmount():new BigDecimal(0));
            }
        }else if("FOB001-27".equals(key) || "FOB004-27".equals(key)){
            SpFobWcxzcbdlfyjs spFobWcxzcbdlfyjs= spFobWcxzcbdlfyjsService.findData(processInstanceId);
            if(spFobWcxzcbdlfyjs!=null){
                A2.setA2(spFobWcxzcbdlfyjs.getPaymentAmount()+"");
                A2.setA3("USD");
                total = total.add(spFobWcxzcbdlfyjs.getPaymentAmount()!=null?spFobWcxzcbdlfyjs.getPaymentAmount():new BigDecimal(0));
            }
        }

        A2.setA3Type("text");
        A2.setA4Type("input");
        A2.setA5Type("input");
        A2.setA6Type("upload");
        tables1.add(A2);
        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setA1("Total");
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setTableId("ShippingAgencyCost");
        A3.setJsfhccbId(costId);
        // 金额
        A3.setA2(total+"");
        A2.setA3("USD");
        A3.setA3Type("text");
        A3.setA4Type("input");
        A3.setA5Type("input");
        A3.setA6Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Shipping agency cost");
        tables1.add(A3);
        return tables1;
    }
    //Insurance
    public List<SpFobJsfhccbItems> table3(Long costId,String processInstanceId,SpDispatchSchemeExecute execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        SpFobGmbx spFobGmbx = spFobGmbxService.findData(processInstanceId);
        // 第三个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setA1("Cargo insurance");
        A1.setA1Type("text");
        A1.setA2Type("number");
        A1.setTableId("Insurance");
        A1.setJsfhccbId(costId);
        A1.setOrderNo(1);
        A1.setTableName("Insurance");
        // 金额
        if(spFobGmbx!=null){
            A1.setA2(spFobGmbx.getFobCost()+"");
            A1.setA3("USD");
        }
        A1.setA3Type("text");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        tables1.add(A1);
        List<SpFobJsfhccbItems> hisItems = spFobJsfhccbItemsMapper.findHistoryData(processInstanceId,"Insurance");
        /*Map<String,String> tempMap = new HashMap<>();
        for(SpFobJsfhccbItems items:hisItems){
            tempMap.put(items.getA1(),items.getA2());
        }*/
        Map<String,String> tempMap =  hisItems.stream().collect(Collectors.toMap(SpFobJsfhccbItems::getA1,t->(t.getA2()==null?"":t.getA2())));

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setA1("Charterer's liability insurance");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setA3("USD");
        A2.setTableId("Insurance");
        A2.setJsfhccbId(costId);
        A2.setA3Type("text");
        A2.setA4Type("input");
        A2.setA5Type("input");
        A2.setA6Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Insurance");
        if(tempMap.containsKey(A2.getA1()) && StringUtils.isNotEmpty(tempMap.get(A2.getA1()))){
            A2.setA2(tempMap.get(A2.getA1()));
        }
        tables1.add(A2);
        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setA1("Total");
        A3.setA1Type("text");
        A3.setA2Type("number");
        if(StringUtils.isNotEmpty(A1.getA2())){
            A3.setA2(A1.getA2());
        }
        A3.setA3("USD");
        A3.setTableId("Insurance");
        A3.setJsfhccbId(costId);
        A3.setA3Type("text");
        A3.setA4Type("input");
        A3.setA5Type("input");
        A3.setA6Type("upload");
        A3.setOrderNo(3);
        A1.setTableName("Insurance");
        if(StringUtils.isNotEmpty(A1.getA2()) && StringUtils.isNotEmpty(A2.getA2())){
            BigDecimal val =  new BigDecimal(A1.getA2()).add(new BigDecimal(A2.getA2()));
            A3.setA2(val+"");
        }
        tables1.add(A3);
        return tables1;
    }
    //LSMGO
    public List<SpFobJsfhccbItems> table4(Long costId,String processInstanceId,SpDispatchSchemeExecute execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setA1("Length of voyage");
        A1.setA1Type("text");
        A1.setA2Type("number");
        A1.setTableId("LSMGO");
        A1.setJsfhccbId(costId);
        A1.setOrderNo(1);
        A1.setTableName("LSMGO");

        String endDate = null;
        if("FOB001-14".equals(key)){ //计算往返航次运费成本
            SpFobQrxzg data = spFobQrxzgService.findData(processInstanceId);
            if(data!=null && data.getExpectedUnloadingPort()!=null){
                endDate = data.getExpectedUnloadingPort();
                //A2.setA2(data.getExpectedUnloadingPort());
            }
        }
        else if("FOB004-14".equals(key)){
            if(execute.getExpectedUnloadingWindow()!=null){
                endDate = CalculateDateUtil.pasrseDate(execute.getExpectedUnloadingWindow());
            }
        }
        else if("FOB001-27".equals(key) || "FOB004-27".equals(key)) { //更新往返航次运费成本
            if(execute.getRealityUnloadingDate()!=null){
                endDate = DateUtil.date2Str(execute.getRealityUnloadingDate(),"yyyy-MM-dd HH:mm:ss");
                //endDate = spFobSyzlxzwj.getUnloadDate().toString();
              //  A2.setA2(endDate);
            }
        }
        //SpFobQrxzg data = spFobQrxzgService.findData(processInstanceId);
        if(execute.getRealityLoadingDate()!=null && endDate!=null){
            String startDate= DateUtil.date2Str(execute.getRealityLoadingDate(),"yyyy-MM-dd HH:mm:ss");
            float nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A1.setA2(nums+"");
        }
        A1.setA3Type("text");
        A1.setA3("days");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        tables1.add(A1);
        List<SpFobJsfhccbItems> hisItems = spFobJsfhccbItemsMapper.findHistoryData(processInstanceId,"LSMGO");
        Map<String,String> tempMap =  hisItems.stream().collect(Collectors.toMap(SpFobJsfhccbItems::getA1,t->(t.getA2()==null?"":t.getA2())));
        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setA1("LSMGO per day");
        A2.setA1Type("text");
        A2.setA2Type("number");
        if(tempMap.containsKey(A2.getA1()) && StringUtils.isNotEmpty(tempMap.get(A2.getA1()))){
            A2.setA2(tempMap.get(A2.getA1()));
        }
        A2.setA3Type("text");
        A2.setTableId("LSMGO");
        A2.setJsfhccbId(costId);
        A2.setA3("tonnes");
        A2.setA4Type("input");
        A2.setA5Type("input");
        A2.setA6Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("LSMGO");
        tables1.add(A2);
        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setA1("LSMGO in port per day");
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setA3Type("text");
        A3.setA3("tonnes");
        A3.setA4Type("input");
        A3.setA5Type("input");
        A3.setA6Type("upload");
        A3.setTableId("LSMGO");
        A3.setOrderNo(3);
        A3.setTableName("LSMGO");
        A3.setJsfhccbId(costId);
        if(tempMap.containsKey(A3.getA1()) && StringUtils.isNotEmpty(tempMap.get(A3.getA1()))){
            A3.setA2(tempMap.get(A3.getA1()));
        }
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setA1("LSMGO unit Price");
        A4.setA1Type("text");
        A4.setA2Type("number");
        A4.setA3Type("text");
        A4.setA3("USD/tonne");
        A4.setA4Type("input");
        A4.setA5Type("input");
        A4.setA6Type("upload");
        A4.setTableId("LSMGO");
        A4.setJsfhccbId(costId);
        A4.setOrderNo(4);
        A4.setTableName("LSMGO");
        if(tempMap.containsKey(A4.getA1()) && StringUtils.isNotEmpty(tempMap.get(A4.getA1()))){
            A4.setA2(tempMap.get(A4.getA1()));
        }
        tables1.add(A4);
        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setA1("Total");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3Type("text");
        A5.setA3("USD");
        A5.setA4Type("input");
        A5.setA5Type("input");
        A5.setA6Type("upload");
        A5.setTableId("LSMGO");
        A5.setJsfhccbId(costId);
        A5.setOrderNo(5);
        A5.setTableName("LSMGO");
        tables1.add(A5);
        return tables1;
    }
    //VLSFO
    public List<SpFobJsfhccbItems> table5(Long costId,String processInstanceId,SpDispatchSchemeExecute execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("VLSFO");
        A1.setA1("Length of voyage");
        A1.setA1Type("text");
        A1.setA2Type("number");
        String endDate = null;
        if("FOB001-14".equals(key)){ //计算往返航次运费成本
            SpFobQrxzg data = spFobQrxzgService.findData(processInstanceId);
            if(data!=null && data.getExpectedUnloadingPort()!=null){
                endDate = data.getExpectedUnloadingPort();
                //A2.setA2(data.getExpectedUnloadingPort());
            }else if(execute.getExpectedUnloadingWindow()!=null){
                endDate = CalculateDateUtil.pasrseDate(execute.getExpectedUnloadingWindow());
            }
        }else if("FOB004-14".equals(key)){
            if(execute.getExpectedUnloadingWindow()!=null){
                endDate = CalculateDateUtil.pasrseDate(execute.getExpectedUnloadingWindow());
            }
        }else if("FOB001-27".equals(key) || "FOB004-27".equals(key)) { //更新往返航次运费成本
            if(execute.getRealityUnloadingDate()!=null){
                endDate = DateUtil.date2Str(execute.getRealityUnloadingDate(),"yyyy-MM-dd HH:mm:ss");
                //endDate = spFobSyzlxzwj.getUnloadDate().toString();
               // A2.setA2(endDate);
            }
        }
        //SpFobQrxzg data = spFobQrxzgService.findData(processInstanceId);
        if(execute.getRealityLoadingDate()!=null && endDate!=null){
            String startDate= DateUtil.date2Str(execute.getRealityLoadingDate(),"yyyy-MM-dd HH:mm:ss");
            float nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A1.setA2(nums+"");
        }
        A1.setA3Type("text");
        A1.setA3("days");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("VLSFO");
        A1.setJsfhccbId(costId);
        tables1.add(A1);
        List<SpFobJsfhccbItems> hisItems = spFobJsfhccbItemsMapper.findHistoryData(processInstanceId,"VLSFO");
        Map<String,String> tempMap =  hisItems.stream().collect(Collectors.toMap(SpFobJsfhccbItems::getA1,t->(t.getA2()==null?"":t.getA2())));

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setA1("VLSFO per day");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setA3Type("text");
        A2.setA3("tonnes");
        A2.setA4Type("input");
        A2.setA5Type("input");
        A2.setA6Type("upload");
        A2.setTableId("VLSFO");
        A2.setOrderNo(2);
        A2.setTableName("VLSFO");
        A2.setJsfhccbId(costId);
        if(tempMap.containsKey(A2.getA1()) && StringUtils.isNotEmpty(tempMap.get(A2.getA1()))){
            A2.setA2(tempMap.get(A2.getA1()));
        }
        tables1.add(A2);
        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setA1("VLSFO unit Price");
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setA3Type("text");
        A3.setA3("USD/tonne");
        A3.setA4Type("input");
        A3.setA5Type("input");
        A3.setA6Type("upload");
        A3.setTableId("VLSFO");
        A3.setJsfhccbId(costId);
        A3.setOrderNo(3);
        A3.setTableName("VLSFO");
        if(tempMap.containsKey(A3.getA1()) && StringUtils.isNotEmpty(tempMap.get(A3.getA1()))){
            A3.setA2(tempMap.get(A3.getA1()));
        }
        tables1.add(A3);
        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setA1("Total");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3Type("text");
        A5.setA3("USD");
        A5.setA4Type("input");
        A5.setA5Type("input");
        A5.setA6Type("upload");
        A5.setTableId("VLSFO");
        A5.setOrderNo(4);
        A5.setTableName("VLSFO");
        if(StringUtils.isNotEmpty(A1.getA2()) && StringUtils.isNotEmpty(A2.getA2()) && StringUtils.isNotEmpty(A3.getA2())){
            BigDecimal num = new BigDecimal(A1.getA2()).multiply(new BigDecimal(A2.getA2())).multiply(new BigDecimal(A3.getA2()));
            num = num.setScale(4, BigDecimal.ROUND_DOWN);
            A5.setA2(num+"");
        }
        A5.setJsfhccbId(costId);
        tables1.add(A5);
        return tables1;
    }
    //Positioning fee
    public List<SpFobJsfhccbItems> table6(Long costId,String processInstanceId,SpDispatchSchemeExecute execute){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        List<SpFobJsfhccbItems> hisItems = spFobJsfhccbItemsMapper.findHistoryData(processInstanceId,"PositioningFee");
        Map<String,String> tempMap =  hisItems.stream().collect(Collectors.toMap(SpFobJsfhccbItems::getA1,t->(t.getA2()==null?"":t.getA2())));

        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("PositioningFee");
        A1.setA1("Positioning fee");
        A1.setA1Type("text");
        A1.setA2Type("number");
        A1.setA3Type("text");
        A1.setA3("USD");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        A1.setJsfhccbId(costId);
        A1.setOrderNo(1);
        A1.setTableName("Positioning fee");
        if(tempMap.containsKey(A1.getA1()) && StringUtils.isNotEmpty(tempMap.get(A1.getA1()))){
            A1.setA2(tempMap.get(A1.getA1()));
        }
        tables1.add(A1);
        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setA1("Total");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3Type("text");
        A5.setA3("USD");
        A5.setA4Type("input");
        A5.setA5Type("input");
        A5.setA6Type("upload");
        A5.setTableId("PositioningFee");
        A5.setJsfhccbId(costId);
        A5.setOrderNo(2);
        A5.setTableName("Positioning fee");
        if(tempMap.containsKey(A5.getA1()) && StringUtils.isNotEmpty(tempMap.get(A5.getA1()))){
            A5.setA2(tempMap.get(A5.getA1()));
        }
        tables1.add(A5);
        return tables1;
    }
    //Ballast Bonus
    public List<SpFobJsfhccbItems> table7(Long costId,String processInstanceId,SpDispatchSchemeExecute execute){
        List<SpFobJsfhccbItems> hisItems = spFobJsfhccbItemsMapper.findHistoryData(processInstanceId,"BallastBonus");
        Map<String,String> tempMap =  hisItems.stream().collect(Collectors.toMap(SpFobJsfhccbItems::getA1,t->(t.getA2()==null?"":t.getA2())));

        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("BallastBonus");
        A1.setA1("Ballast Bonus");
        A1.setA1Type("text");
        A1.setA2Type("number");
        A1.setA3Type("text");
        A1.setA3("USD");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Ballast Bonus");
        A1.setJsfhccbId(costId);
        if(tempMap.containsKey(A1.getA1()) && StringUtils.isNotEmpty(tempMap.get(A1.getA1()))){
            A1.setA2(tempMap.get(A1.getA1()));
        }
        tables1.add(A1);
        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setA1("Total");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3Type("text");
        A5.setA3("USD");
        A5.setA4Type("input");
        A5.setA5Type("input");
        A5.setA6Type("upload");
        A5.setTableId("BallastBonus");
        A5.setJsfhccbId(costId);
        A5.setOrderNo(2);
        A5.setTableName("Ballast Bonus");
        if(tempMap.containsKey(A5.getA1()) && StringUtils.isNotEmpty(tempMap.get(A5.getA1()))){
            A5.setA2(tempMap.get(A5.getA1()));
        }
        tables1.add(A5);
        return tables1;
    }
    //Ballast Bonus
/*
    public List<SpFobJsfhccbItems> table8(String processInstanceId,SpDispatchSchemeExecute execute){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setA1("Ballast Bonus");
        A1.setA1Type("text");
        A1.setA2Type("number");
        A1.setA3Type("text");
        A1.setA3("USD");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        tables1.add(A1);
        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setA1("Total");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3Type("text");
        A5.setA3("USD");
        A5.setA4Type("input");
        A5.setA5Type("input");
        A5.setA6Type("upload");
        tables1.add(A5);
        return tables1;
    }
*/
    //BOG
    public List<SpFobJsfhccbItems> table8(Long costId,String processInstanceId,SpDispatchSchemeExecute execute,String num){
        List<SpFobJsfhccbItems> hisItems = spFobJsfhccbItemsMapper.findHistoryData(processInstanceId,"BOG");
        Map<String,String> tempMap =  hisItems.stream().collect(Collectors.toMap(SpFobJsfhccbItems::getA1,t->(t.getA2()==null?"":t.getA2())));

        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("BOG");
        A1.setA1("Total BOG consumption");
        A1.setA1Type("text");
        A1.setA2Type("number");
        A1.setA3Type("text");
        A1.setA3("m3");
        A1.setA4Type("input");
        A1.setA5Type("input");
        A1.setA6Type("upload");
        A1.setJsfhccbId(costId);
        A1.setOrderNo(1);
        A1.setTableName("BOG");
        if(tempMap.containsKey(A1.getA1()) && StringUtils.isNotEmpty(tempMap.get(A1.getA1()))){
            A1.setA2(tempMap.get(A1.getA1()));
        }
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setA1("Heel price");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setA3Type("text");
        A2.setA3("USD/MMBtu");
        A2.setA4Type("input");
        A2.setA5Type("input");
        A2.setA6Type("upload");
        A2.setTableId("BOG");
        A2.setOrderNo(2);
        A2.setTableName("BOG");
        A2.setJsfhccbId(costId);
        if(tempMap.containsKey(A2.getA1()) && StringUtils.isNotEmpty(tempMap.get(A2.getA1()))){
            A2.setA2(tempMap.get(A2.getA1()));
        }
        tables1.add(A2);
        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setA1("Contract price");
        A3.setA1Type("text");
        A3.setA2Type("number");
        // 资源合同 价格
        Map<String,Object> map = spFobJsfhccbItemsMapper.getResouceMainContract(execute.getResourceContract());
        if(map!=null && map.containsKey("contract_price")){
            A3.setA2(map.get("contract_price")+"");
        }else if(tempMap.containsKey(A3.getA1()) && StringUtils.isNotEmpty(tempMap.get(A3.getA1()))){
            A3.setA2(tempMap.get(A3.getA1()));
        }
        A3.setA3Type("text");
        A3.setA3("USD/MMBtu");
        A3.setA4Type("input");
        A3.setA5Type("input");
        A3.setA6Type("upload");
        A3.setTableId("BOG");
        A3.setOrderNo(3);
        A3.setTableName("BOG");
        A3.setJsfhccbId(costId);
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setA1("Total price");
        A4.setA1Type("text");
        A4.setA2Type("number");
        A4.setA3Type("text");
        A4.setA3("USD");
        A4.setA4Type("input");
        A4.setA5Type("input");
        A4.setA6Type("upload");
        A4.setTableId("BOG");
        A4.setOrderNo(4);
        A4.setTableName("BOG");
        A4.setJsfhccbId(costId);
        if(tempMap.containsKey(A4.getA1()) && StringUtils.isNotEmpty(tempMap.get(A4.getA1()))){
            A4.setA2(tempMap.get(A4.getA1()));
        }
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setA1("Total Transportation cost");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA2(num);
        A5.setA3Type("text");
        A5.setA3("USD");
        A5.setA4Type("input");
        A5.setA5Type("input");
        A5.setA6Type("upload");
        A5.setTableId("BOG");
        A5.setOrderNo(5);
        A5.setTableName("BOG");
        A5.setJsfhccbId(costId);
        tables1.add(A5);
        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setA1("Estimated discharge quantity");
        A6.setA1Type("text");
        A6.setA2Type("number");
        //卸载指令中的卸载数量 @Todo 待注入数据
        SpFobSyzlxzwj spFobSyzlxzwj = spFobSyzlxzwjService.findData(processInstanceId);
        if(spFobSyzlxzwj!=null && spFobSyzlxzwj.getUnloadDate()!=null){
            A6.setA2(spFobSyzlxzwj.getUnloadNum());
        }
        A6.setA3Type("text");
        A6.setA3("MMBtu");
        A6.setA4Type("input");
        A6.setA5Type("input");
        A6.setA6Type("upload");
        A6.setTableId("BOG");
        A6.setOrderNo(6);
        A6.setTableName("BOG");
        A6.setJsfhccbId(costId);
        tables1.add(A6);
        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setA1("Shipping cost");
        A7.setA1Type("text");
        A7.setA2Type("number");
        A7.setA3Type("text");
        A7.setA3("USD/MMBtu");
        A7.setA4Type("input");
        A7.setA5Type("input");
        A7.setA6Type("upload");
        A7.setTableId("BOG");
        A7.setOrderNo(7);
        A7.setTableName("BOG");
        A7.setJsfhccbId(costId);
        if(StringUtils.isNotEmpty(A5.getA2()) && StringUtils.isNotEmpty(A6.getA2()) && !"0".equals(A6.getA2())){
           // if()
            BigDecimal val =  new BigDecimal(A5.getA2()).divide(new BigDecimal(A6.getA2()));
            val =  val.setScale(4, BigDecimal.ROUND_DOWN);
            A7.setA2(val+"");
        }
        tables1.add(A7);
        return tables1;
    }
    //
    public String getPriceUnitName(String key){
        String name = "";
       switch (key){
           case "1":
               name = "USD";
               break;
           case "2":
               name = "CNY";
               break;
           case "3":
               name = "EUR";
               break;
           case "4":
               name = "GBP";
               break;
           case "5":
               name = "CAD";
               break;
           case "6":
               name = "JPY";
               break;
           case "7":
               name = "INR";
               break;
           case "8":
               name = "PENCE";
               break;
           case "9":
               name = "RUB";
               break;
           default:
               name="";
       }
       return name;
    }

    public CharterRateDto getRate(Map<String,Object> map,Date date1){
        CharterRateDto rent = null;
        String json = map.get("rent_time_slot").toString();
        JSONArray res = JSON.parseArray(json);
        List<CharterRateDto> charterRateDtos = res.toJavaList(CharterRateDto.class);
        for(CharterRateDto dto:charterRateDtos) {
            if(date1.compareTo(dto.getRentDateBegin())>=0 && date1.compareTo(dto.getRentDateEnd())<0){
                rent = dto;
                break;
            }
        }
        return rent;
    }

    public void initFob08PartInfo(Long costId,String processInstanceId,String key){
        SpFobSublease execute = spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        List<SpFobJsfhccbItems> tables1 = part81(costId,processInstanceId,execute,key);
        this.saveBatch(tables1);
        List<SpFobJsfhccbItems> tables2 = part82(costId,processInstanceId,execute,key);
        this.saveBatch(tables2);
        List<SpFobJsfhccbItems> tables3 = part83(costId,processInstanceId,execute,key);
        this.saveBatch(tables3);
        List<SpFobJsfhccbItems> tables4 = part84(costId,processInstanceId,execute,key);
        this.saveBatch(tables4);
        List<SpFobJsfhccbItems> tables5 = part85(costId,processInstanceId,execute,key);
        this.saveBatch(tables5);
    }

    public void initFob085PartInfo(Long costId,String processInstanceId,String key){
        SpFobSublease execute = spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        List<SpFobJsfhccbItems> tables1 = part815(costId,processInstanceId,execute,key);
        this.saveBatch(tables1);
        List<SpFobJsfhccbItems> tables2 = part825(costId,processInstanceId,execute,key);
        this.saveBatch(tables2);
        List<SpFobJsfhccbItems> tables3 = part835(costId,processInstanceId,execute,key);
        this.saveBatch(tables3);
        List<SpFobJsfhccbItems> tables4 = part845(costId,processInstanceId,execute,key);
        this.saveBatch(tables4);
        List<SpFobJsfhccbItems> tables5 = part855(costId,processInstanceId,execute,key);
        this.saveBatch(tables5);
    }


    public Date nextMonthDays(Date date){
        Instant instant = date.toInstant();
        LocalDate today = instant.atZone(ZoneId.systemDefault()).toLocalDate();
        LocalDate lastDayOfNextMonth = today.with(TemporalAdjusters.lastDayOfMonth()).plusMonths(1);
        LocalTime time = LocalTime.MAX;
        LocalDateTime localDateTime = lastDayOfNextMonth.atTime(time);
        Date endDate = Date.from(lastDayOfNextMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
        return endDate;
    }

    public Date upMonthDays(Date date){
        Instant instant = date.toInstant();
        LocalDate today = instant.atZone(ZoneId.systemDefault()).toLocalDate();
        // 设置日期为上个月的第一天
        LocalDate firstDayOfPreviousMonth = today.minusMonths(1).withDayOfMonth(1);

        // 获取上个月最后一天
        LocalDate lastDayOfPreviousMonth = firstDayOfPreviousMonth.withDayOfMonth(firstDayOfPreviousMonth.lengthOfMonth());
        Date endDate = Date.from(lastDayOfPreviousMonth.atStartOfDay(ZoneId.systemDefault()).toInstant());
        return endDate;
    }


    public List<SpFobJsfhccbItems> part81(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part1");
        A1.setJsfhccbId(costId);
        A1.setA1("交船日期");
        A1.setA1Type("text");
        A1.setA2Type("date");
        // 实际装载时间
        String startDate = null;
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc()!=null){
            startDate = DateUtil.date2Str(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A1.setA2(startDate);
        }
        A1.setA3Type("select");
        A1.setA3("UTC");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part1（运费=交船结算-交船天数差×租金）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part1");
        A2.setJsfhccbId(costId);
        A2.setA1("交船结算截止日期");
        A2.setA1Type("text");
        A2.setA2Type("date");
        String endDate = null;
        //SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate =  spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc()!=null){
            endDate = DateUtil.date2Str(nextMonthDays(spFobSubleaseDeliveryUpdate.getDeliveryDateUtc()),"yyyy-MM-dd");
            endDate = endDate+" 23:59:59";
            A2.setA2(endDate);
        }
        A2.setA3Type("input");
        A2.setA3("UTC");
        A2.setA4Type("input");
        A2.setA4("见租船合同TCP，默认为下个月的最后一天");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part1（运费=交船结算-交船天数差×租金）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part1");
        A3.setJsfhccbId(costId);
        A3.setA1("租金");
        A3.setA1Type("text");
        A3.setA2Type("input");

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        String rent = null;
        if(conShipping!=null){
            rent = conShipping.getRent()+"";
            A3.setA2(rent);
        }
        A3.setA3Type("input");
        A3.setA3(getPriceUnitName(conShipping.getCurrency()+""));
        A3.setA4Type("input");
        A3.setA4("见租船合同TCP");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part1（运费=交船结算-交船天数差×租金）");
        tables1.add(A3);


        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part1");
        A5.setJsfhccbId(costId);
        A5.setA1("租船天数");
        A5.setA1Type("text");
        A5.setA2Type("input");
        float nums = 0;
        if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
            // 时间差
            nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A5.setA2(nums+"");
        }
        A5.setA3("天");
        A5.setA3Type("text");
        A5.setA4("租船天数=交船结算截止日期-交船日期");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(4);
        A5.setTableName("Part1（运费=交船结算-交船天数差×租金）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part1");
        A6.setJsfhccbId(costId);
        A6.setA1("租金结算");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(nums!=0 && rent!=null){
            // 时间差
            double re = nums*Float.parseFloat(rent);
            A6.setA2(re+"");
        }
        A6.setA3("USD");
        A6.setA3Type("text");
        A6.setA4("租金=租船天数*租金");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(5);
        A6.setTableName("Part1（运费=交船结算-交船天数差×租金）");
        tables1.add(A6);
        return tables1;
    }

    public List<SpFobJsfhccbItems> part82(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part2");
        A1.setJsfhccbId(costId);
        A1.setA1("航距");
        A1.setA1Type("text");
        A1.setA2Type("input");
        A1.setA3Type("text");
        A1.setA3("海里");
        A1.setA4Type("input");
        A1.setA4("Dataloy查询得出");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part2（交船费租金部分）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part2");
        A2.setJsfhccbId(costId);
        A2.setA1("航速");
        A2.setA1Type("text");
        A2.setA2Type("input");
        A2.setA2("16");
        A2.setA3Type("text");
        A2.setA3("节");
        A2.setA4Type("input");
        A2.setA4("TCP约定的还船费计算速度");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part2（交船费租金部分）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part2");
        A3.setJsfhccbId(costId);
        A3.setA1("航行天数");
        A3.setA1Type("text");
        A3.setA2Type("input");

        A3.setA3Type("text");
        A3.setA3("天");
        A3.setA4Type("input");
        A3.setA4("航行天数=航距/航速/24");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part2（交船费租金部分）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part2");
        A4.setJsfhccbId(costId);
        A4.setA1("交船费租金部分");
        A4.setA1Type("text");
        A4.setA2Type("input");
        ConShipping conShipping = conShippingService.getById(execute.getConId());
        A4.setA3(getPriceUnitName(conShipping.getCurrency()+""));
        A4.setA3Type("text");
        A4.setA4("租金部分=租金*航行天数");
        A4.setA4Type("text");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part2（交船费租金部分）");
        tables1.add(A4);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part83(Long costId,String processInstanceId,SpFobSublease execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        ConShipping conShipping = conShippingService.getById(execute.getConId());

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part3");
        A5.setJsfhccbId(costId);
        A5.setA1("油耗");
        A5.setA1Type("text");
        A5.setA2Type("input");
        if(conShipping!=null){
            A5.setA2(conShipping.getShipSpeedForRedeliveryFee()+"");
        }
        A5.setA3("t/day");
        A5.setA3Type("text");
        A5.setA4("从船舶Form B查询得出，对应16节空载的油耗");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(1);
        A5.setTableName("Part3（交船费燃油部分）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part3");
        A6.setJsfhccbId(costId);
        A6.setA1("燃油消耗");
        A6.setA1Type("text");
        A6.setA2Type("input");
        A6.setA3("t");
        A6.setA3Type("text");
        A6.setA4("燃油消耗=油耗*交船费租金部分计算的航行天数");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(2);
        A6.setTableName("Part3（交船费燃油部分）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part3");
        A7.setJsfhccbId(costId);
        A7.setA1("FOE");
        A7.setA1Type("text");
        A7.setA2Type("input");

        if(conShipping!=null){
            A7.setA2(conShipping.getFoe()+"");
        }
        A7.setA3("");
        A7.setA3Type("text");
        A7.setA4("燃油(吨)/LNG（立方米）转换系数，TCP约定");
        A7.setA4Type("text");
        A7.setA5Type("upload");
        A7.setOrderNo(3);
        A7.setTableName("Part3（交船费燃油部分）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part3");
        A8.setJsfhccbId(costId);
        A8.setA1("LNG消耗");
        A8.setA1Type("text");
        A8.setA2Type("input");
        A8.setA3("m³");
        A8.setA3Type("text");
        A8.setA4("LNG消耗=燃油消耗/FOE");
        A8.setA4Type("text");
        A8.setA5Type("upload");
        A8.setOrderNo(4);
        A8.setTableName("Part3（交船费燃油部分）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part3");
        A9.setJsfhccbId(costId);
        A9.setA1("所载LNG热值");
        A9.setA1Type("text");
        A9.setA2Type("input");
        A9.setA3("MMBtu");
        A9.setA3Type("text");
        A9.setA4Type("text");
        A9.setA5Type("upload");
        A9.setOrderNo(5);
        A9.setTableName("Part3（交船费燃油部分）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part3");
        A10.setJsfhccbId(costId);
        A10.setA1("所载LNG体积");
        A10.setA1Type("text");
        A10.setA2Type("input");
        A10.setA3("m³");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA5Type("upload");
        A10.setOrderNo(6);
        A10.setTableName("Part3（交船费燃油部分）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part3");
        A11.setJsfhccbId(costId);
        A11.setA1("FC");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("MMBtu/m³");
        A11.setA3Type("text");
        A11.setA4Type("text");
        A11.setA4("交船Heel热值系数转换规则");
        A11.setA5Type("upload");
        A11.setOrderNo(7);
        A11.setTableName("Part3（交船费燃油部分）");
        tables1.add(A11);

        SpFobJsfhccbItems A12 = new SpFobJsfhccbItems();
        A12.setTableId("Part3");
        A12.setJsfhccbId(costId);
        A12.setA1("LNG价格（DES）");
        A12.setA1Type("text");
        A12.setA2Type("input");
        A12.setA3("USD/MMbtu");
        A12.setA3Type("text");
        A12.setA4Type("text");
        A12.setA4("同步交船Heel单价规则");
        A12.setA5Type("upload");
        A12.setOrderNo(8);
        A12.setTableName("Part3（交船费燃油部分）");
        tables1.add(A12);

        SpFobJsfhccbItems A13 = new SpFobJsfhccbItems();
        A13.setTableId("Part3");
        A13.setJsfhccbId(costId);
        A13.setA1("交船费燃油部分");
        A13.setA1Type("text");
        A13.setA2Type("input");
        A13.setA3("USD");
        A13.setA3Type("text");
        A13.setA4Type("text");
        A13.setA4("燃油部分=LNG消耗（m³）*FC*LNG价格");
        A13.setA5Type("upload");
        A13.setOrderNo(9);
        A13.setTableName("Part3（交船费燃油部分）");
        tables1.add(A13);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part84(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part4");
        A1.setJsfhccbId(costId);
        A1.setA1("交船时LSMGO1");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate!=null){
            A1.setA2(spFobSubleaseDeliveryUpdate.getLsmgo());
        }

        A1.setA3Type("text");
        A1.setA3("T");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A1);
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part4");
        A2.setJsfhccbId(costId);
        A2.setA1("交船时LSMGO2");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setA3Type("text");
        A2.setA3("T");
        A2.setA4Type("input");
        A2.setA4("");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part4");
        A3.setJsfhccbId(costId);
        A3.setA1("交船LSMGO 单价 1");
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setA3Type("text");
        A3.setA3("T");
        A3.setA4Type("input");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part4");
        A4.setJsfhccbId(costId);
        A4.setA1("交船LSMGO 单价 2");
        A4.setA1Type("text");
        A4.setA2Type("number");
        A4.setA3("USD/T");
        A4.setA3Type("text");
        A4.setA4("");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part4");
        A5.setJsfhccbId(costId);
        A5.setA1("4.1LSMGO结算");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3("USD");
        A5.setA3Type("text");
        A5.setA4("4.1LSMGO结算=交船时LSMGO1*LSMGO单价1+交船时LSMGO2*LSMGO单价2");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part4");
        A6.setJsfhccbId(costId);
        A6.setA1("交船时VLSFO1");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(spFobSubleaseDeliveryUpdate!=null){
            A6.setA2(spFobSubleaseDeliveryUpdate.getVisfo());
        }
        A6.setA3("T");
        A6.setA3Type("text");
        A6.setA4("见交船通知");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part4");
        A7.setJsfhccbId(costId);
        A7.setA1("交船时VLSFO2");
        A7.setA1Type("text");
        A7.setA2Type("input");
        A7.setA3("T");
        A7.setA3Type("text");
        //A7.setA4("见交船通知");
        A7.setA4Type("input");
        A7.setA5Type("upload");
        A7.setOrderNo(7);
        A7.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part4");
        A8.setJsfhccbId(costId);
        A8.setA1("交船VLSFO 单价 1");
        A8.setA1Type("text");
        A8.setA2Type("number");
        A8.setA3("USD");
        A8.setA3Type("text");
       // A8.setA4("VLSFO 部分 1=交船时VLSFO-还船时VLSFO");
        A8.setA4Type("input");
        A8.setA5Type("upload");
        A8.setOrderNo(8);
        A8.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part4");
        A9.setJsfhccbId(costId);
        A9.setA1("交船VLSFO 单价 2");
        A9.setA1Type("text");
        A9.setA2Type("number");
        A9.setA3("USD/T");
        A9.setA3Type("text");
        A9.setA4Type("input");
        A9.setA5Type("upload");
        A9.setOrderNo(9);
        A9.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part4");
        A10.setJsfhccbId(costId);
        A10.setA1("4.2VLSFO结算");
        A10.setA1Type("text");
        A10.setA2Type("number");
        A10.setA3("USD");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA4("VLSFO结算=交船时VLSFO1*VLSFO单价 1+交船时VLSFO2*VLSFO单价2");
        A10.setA5Type("upload");
        A10.setOrderNo(10);
        A10.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part4");
        A11.setJsfhccbId(costId);
        A11.setA1("燃油部分结算");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("USD");
        A11.setA3Type("text");
        A11.setA4Type("input");
        A11.setA4("燃油部分结算=4.1LSMGO结算+4.2 VLSFO结算");
        A11.setA5Type("upload");
        A11.setOrderNo(11);
        A11.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A11);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part85(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part5");
        A1.setJsfhccbId(costId);
        A1.setA1("交船LNG");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseDeliveryUpdate spFobSubleaseDeliveryUpdate =  spFobSubleaseDeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseDeliveryUpdate!=null){
            A1.setA2(spFobSubleaseDeliveryUpdate.getLng());
        }
        A1.setA3Type("text");
        A1.setA3("m³");
        A1.setA4Type("input");
        A1.setA4("见交船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part5");
        A2.setJsfhccbId(costId);
        A2.setA1("交船Heel单价");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setA3Type("text");
       // A2.setA3("T");
        A2.setA4Type("input");
        //A2.setA4("见交船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
        tables1.add(A2);
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part5");
        A3.setJsfhccbId(costId);
        A3.setA1("交船FC热值系数");
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setA3Type("text");
       // A3.setA3("T");
        A3.setA4Type("input");
        A3.setA4("");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part5");
        A4.setJsfhccbId(costId);
        A4.setA1("交船时LNG总价");
        A4.setA1Type("text");
        A4.setA2Type("number");
        A4.setA3("USD");
        A4.setA3Type("input");
        A4.setA4("");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part5");
        A5.setJsfhccbId(costId);
        A5.setA1("LNG底角结算");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3("USD");
        A5.setA3Type("text");
        A5.setA4("LNG底角结算=交船时LNG总价");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part5");
        A6.setJsfhccbId(costId);
        A6.setA1("自定义金额");
        A6.setA1Type("text");
        A6.setA2Type("number");
        A6.setA3("USD");
        A6.setA3Type("text");
        A6.setA4("");
        A6.setA4Type("input");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
        tables1.add(A6);


        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getCurrency()!=null && conShipping.getCurrency()==3){
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part5");
            A8.setJsfhccbId(costId);
            A8.setA1("合计1");
            A8.setA1Type("text");
            A8.setA2Type("number");
            A8.setA3("EUR");
            A8.setA3Type("text");
            A8.setA4("合计 1=租金结算+交船费租金部分");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
            tables1.add(A8);
            SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
            A9.setTableId("Part5");
            A9.setJsfhccbId(costId);
            A9.setA1("合计2");
            A9.setA1Type("text");
            A9.setA2Type("number");
            A9.setA3("USD");
            A9.setA3Type("text");
            A9.setA4("合计 2= 交船费燃油部分+燃油结算+LNG底角结算");
            A9.setA4Type("input");
            A9.setA5Type("upload");
            A9.setOrderNo(9);
            A9.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
            tables1.add(A9);
        }else {
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part5");
            A8.setJsfhccbId(costId);
            A8.setA1("合计");
            A8.setA1Type("text");
            A8.setA2Type("number");
            A8.setA3("USD");
            A8.setA3Type("text");
           // A8.setA4("合计=租金结算+还船费结算+燃油结算+LNG 底角结算");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part5（LNGHeel结算=交船时LNG总价）");
            tables1.add(A8);
        }
        return tables1;
    }

    public Map<String,Object> valPartFob08(List<SpFobJsfhccbItems> list,String processInstanceId,String key){
        SpFobSublease execute =  spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        Map<String,Object> node = new HashMap<>();
        List<SpFobJsfhccbItems> tables1 = list.stream().filter(item->item.getTableId().equals("Part1")).collect(Collectors.toList());
        tables1 = bingTableUploadA5Record(tables1);
        List<SpFobJsfhccbItems> tables2 = list.stream().filter(item->item.getTableId().equals("Part2")).collect(Collectors.toList());
        tables2 = bingTableUploadA5Record(tables2);
        List<SpFobJsfhccbItems> tables3 = list.stream().filter(item->item.getTableId().equals("Part3")).collect(Collectors.toList());
        tables3 = bingTableUploadA5Record(tables3);
        List<SpFobJsfhccbItems> tables4 = list.stream().filter(item->item.getTableId().equals("Part4")).collect(Collectors.toList());
        tables4 = bingTableUploadA5Record(tables4);
        List<SpFobJsfhccbItems> tables5 = list.stream().filter(item->item.getTableId().equals("Part5")).collect(Collectors.toList());
        tables5 = bingTableUploadA5Record(tables5);

        List<BGTableDto> bgTableDtos = new ArrayList<>();
        BGTableDto dto = new BGTableDto();
        dto.setTableId("Part1");
        dto.setTableName("Part1（运费=交船结算-交船天数差×租金）");
        dto.setTables(tables1);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part2");
        dto.setTableName("Part2（交船费租金部分）");
        dto.setTables(tables2);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part3");
        dto.setTableName("Part3（交船费燃油部分）");
        dto.setTables(tables3);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("Part4");
        dto.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        dto.setTables(tables4);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part5");
        dto.setTableName("Part 5（LNG Heel结算=交船时 LNG 总价）");
        dto.setTables(tables5);
        bgTableDtos.add(dto);
        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getTradeBody()==1){
            node.put("currentTradeBody","国贸");
            node.put("upTradeBody","新贸");
        }else{
            node.put("currentTradeBody","新贸");
            node.put("upTradeBody","国贸");
        }
        node.put("tenant",conShipping.getTenant());
        node.put("shipowner",conShipping.getShipowner());
        node.put("shipName",execute.getShipName());
        node.put("data",bgTableDtos);
        return node;
    }

    public List<SpFobJsfhccbItems> part815(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate =  spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part1");
        A2.setJsfhccbId(costId);
        A2.setA1("还船结算开始日期");
        A2.setA1Type("text");
        A2.setA2Type("date");
        String startDate = null;
        if(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc()!=null){
            startDate = DateUtil.date2Str(upMonthDays(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc()),"yyyy-MM-dd");
            startDate = startDate+" 00:00:00";
            A2.setA2(startDate);
        }
        A2.setA3Type("select");
        A2.setA3("UTC");
        A2.setA4Type("input");
        A2.setA4("见租船合同TCP，默认为下个月的最后一天");
        A2.setA5Type("upload");
        A2.setOrderNo(1);
        A2.setTableName("Part1（运费=还船还船天数差×租金）");
        tables1.add(A2);
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part1");
        A1.setJsfhccbId(costId);
        A1.setA1("还船日期");
        A1.setA1Type("text");
        A1.setA2Type("date");
        // 实际装载时间
        String endDate = null;
        if(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc()!=null){
            endDate = DateUtil.date2Str(spFobSubleaseRedeliveryUpdate.getRedeliveryDateUtc(),"yyyy-MM-dd HH:mm:ss");
            A1.setA2(endDate);
        }
        A1.setA3Type("select");
        A1.setA3("UTC");
        A1.setA4Type("input");
        A1.setA4("见还船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(2);
        A1.setTableName("Part1（运费=还船还船天数差×租金）");
        tables1.add(A1);



        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part1");
        A3.setJsfhccbId(costId);
        A3.setA1("租金");
        A3.setA1Type("text");
        A3.setA2Type("input");

        ConShipping conShipping = conShippingService.getById(execute.getConId());
        String rent = null;
        if(conShipping!=null){
            rent = conShipping.getRent()+"";
            A3.setA2(rent);
        }
        A3.setA3Type("input");
        A3.setA3(getPriceUnitName(conShipping.getCurrency()+""));
        A3.setA4Type("input");
        A3.setA4("见租船合同TCP");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part1（运费=还船还船天数差×租金）");
        tables1.add(A3);


        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part1");
        A5.setJsfhccbId(costId);
        A5.setA1("租船天数");
        A5.setA1Type("text");
        A5.setA2Type("input");
        float nums = 0;
        if(StringUtils.isNotEmpty(startDate) && StringUtils.isNotEmpty(endDate)){
            // 时间差
            nums = CalculateDateUtil.getBetweenDays(startDate,endDate);
            A5.setA2(nums+"");
        }
        A5.setA3("天");
        A5.setA3Type("text");
        A5.setA4("租船天数=还船日期-还船结算开始日期");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(4);
        A5.setTableName("Part1（运费=还船还船天数差×租金）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part1");
        A6.setJsfhccbId(costId);
        A6.setA1("租金结算");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(nums!=0 && rent!=null){
            // 时间差
            double re = nums*Float.parseFloat(rent);
            A6.setA2(re+"");
        }
        //A3.setA3(getPriceUnitName(conShipping.getCurrency()+""));
        A6.setA3(getPriceUnitName(conShipping.getCurrency()+""));
        A6.setA3Type("text");
        A6.setA4("租金=租船天数*租金");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(5);
        A6.setTableName("Part1（运费=交船结算-交船天数差×租金）");
        tables1.add(A6);
        return tables1;
    }

    public List<SpFobJsfhccbItems> part825(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part2");
        A1.setJsfhccbId(costId);
        A1.setA1("航距");
        A1.setA1Type("text");
        A1.setA2Type("input");
        A1.setA3Type("text");
        A1.setA3("海里");
        A1.setA4Type("input");
        A1.setA4("Dataloy查询得出");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part2（还船费租金部分）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part2");
        A2.setJsfhccbId(costId);
        A2.setA1("航速");
        A2.setA1Type("text");
        A2.setA2Type("input");
        A2.setA2("16");
        A2.setA3Type("text");
        A2.setA3("节");
        A2.setA4Type("input");
        A2.setA4("TCP约定的还船费计算速度");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part2（还船费租金部分）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part2");
        A3.setJsfhccbId(costId);
        A3.setA1("航行天数");
        A3.setA1Type("text");
        A3.setA2Type("input");
        ConShipping conShipping = conShippingService.getById(execute.getConId());
        A3.setA3Type("text");
        A3.setA3("天");
        A3.setA4Type("input");
        A3.setA4("航行天数=航距/航速/24");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part2（还船费租金部分）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part2");
        A4.setJsfhccbId(costId);
        A4.setA1("还船费租金部分");
        A4.setA1Type("text");
        A4.setA2Type("input");
        A4.setA3(getPriceUnitName(conShipping.getCurrency()+""));
        A4.setA3Type("text");
        A4.setA4("2.1租金部分=租金*还船费的航行天数");
        A4.setA4Type("text");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part2（还船费租金部分）");
        tables1.add(A4);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part835(Long costId,String processInstanceId,SpFobSublease execute,String key){
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        ConShipping conShipping = conShippingService.getById(execute.getConId());

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part3");
        A5.setJsfhccbId(costId);
        A5.setA1("油耗");
        A5.setA1Type("text");
        A5.setA2Type("input");
        if(conShipping!=null){
            A5.setA2(conShipping.getShipSpeedForRedeliveryFee()+"");
        }
        A5.setA3("FOE t/day");
        A5.setA3Type("text");
        A5.setA4("从船舶Form B查询得出，对应16节空载的油耗");
        A5.setA4Type("text");
        A5.setA5Type("upload");
        A5.setOrderNo(1);
        A5.setTableName("Part3（交船费燃油部分）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part3");
        A6.setJsfhccbId(costId);
        A6.setA1("燃油消耗");
        A6.setA1Type("text");
        A6.setA2Type("input");
        A6.setA3("t");
        A6.setA3Type("text");
        A6.setA4("燃油消耗=油耗*交船费租金部分计算的航行天数");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(2);
        A6.setTableName("Part3（还船费燃油部分）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part3");
        A7.setJsfhccbId(costId);
        A7.setA1("FOE");
        A7.setA1Type("text");
        A7.setA2Type("input");
        if(conShipping!=null){
            A7.setA2(conShipping.getFoe()+"");
        }
        A7.setA3("");
        A7.setA3Type("text");
        A7.setA4("燃油(吨)/LNG（立方米）转换系数，TCP约定");
        A7.setA4Type("text");
        A7.setA5Type("upload");
        A7.setOrderNo(3);
        A7.setTableName("Part3（还船费燃油部分）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part3");
        A8.setJsfhccbId(costId);
        A8.setA1("LNG消耗");
        A8.setA1Type("text");
        A8.setA2Type("input");
        A8.setA3("m³");
        A8.setA3Type("text");
        A8.setA4("LNG消耗=燃油消耗/FOE");
        A8.setA4Type("text");
        A8.setA5Type("upload");
        A8.setOrderNo(4);
        A8.setTableName("Part3（还船费燃油部分）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part3");
        A9.setJsfhccbId(costId);
        A9.setA1("所载LNG热值");
        A9.setA1Type("text");
        A9.setA2Type("input");
        A9.setA3("MMBtu");
        A9.setA3Type("text");
        A9.setA4Type("text");
        A9.setA5Type("upload");
        A9.setOrderNo(5);
        A9.setTableName("Part3（还船费燃油部分）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part3");
        A10.setJsfhccbId(costId);
        A10.setA1("所载LNG体积");
        A10.setA1Type("text");
        A10.setA2Type("input");
        A10.setA3("m³");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA5Type("upload");
        A10.setOrderNo(6);
        A10.setTableName("Part3（还船费燃油部分）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part3");
        A11.setJsfhccbId(costId);
        A11.setA1("FC");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("MMBtu/m³");
        A11.setA3Type("text");
        A11.setA4Type("text");
        A11.setA4("还船Heel热值系数转换规则");
        A11.setA5Type("upload");
        A11.setOrderNo(7);
        A11.setTableName("Part3（还船费燃油部分）");
        tables1.add(A11);

        SpFobJsfhccbItems A12 = new SpFobJsfhccbItems();
        A12.setTableId("Part3");
        A12.setJsfhccbId(costId);
        A12.setA1("LNG价格（DES）");
        A12.setA1Type("text");
        A12.setA2Type("input");
        A12.setA3("USD/MMbtu");
        A12.setA3Type("text");
        A12.setA4Type("text");
        A12.setA4("同步还船Heel单价规则");
        A12.setA5Type("upload");
        A12.setOrderNo(8);
        A12.setTableName("Part3（还船费燃油部分）");
        tables1.add(A12);

        SpFobJsfhccbItems A13 = new SpFobJsfhccbItems();
        A13.setTableId("Part3");
        A13.setJsfhccbId(costId);
        A13.setA1("还船费燃油部分");
        A13.setA1Type("text");
        A13.setA2Type("input");
        A13.setA3("USD");
        A13.setA3Type("text");
        A13.setA4Type("text");
        A13.setA4("燃油部分=LNG消耗（m³）*FC*LNG价格");
        A13.setA5Type("upload");
        A13.setOrderNo(9);
        A13.setTableName("Part3（还船费燃油部分）");
        tables1.add(A13);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part845(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part4");
        A1.setJsfhccbId(costId);
        A1.setA1("还船时LSMGO1");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseRedeliveryUpdate!=null){
            A1.setA2(spFobSubleaseRedeliveryUpdate.getLsmgo());
        }

        A1.setA3Type("text");
        A1.setA3("T");
        A1.setA4Type("input");
        A1.setA4("见还船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part4");
        A2.setJsfhccbId(costId);
        A2.setA1("还船时LSMGO2");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setA3Type("text");
        A2.setA3("T");
        A2.setA4Type("input");
        A2.setA4("");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A2);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part4");
        A3.setJsfhccbId(costId);
        A3.setA1("还船LSMGO 单价 1");
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setA3Type("text");
        A3.setA3("T");
        A3.setA4Type("input");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part4");
        A4.setJsfhccbId(costId);
        A4.setA1("还船LSMGO 单价 2");
        A4.setA1Type("text");
        A4.setA2Type("number");
        A4.setA3("USD/T");
        A4.setA3Type("text");
        A4.setA4("");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part4");
        A5.setJsfhccbId(costId);
        A5.setA1("4.1LSMGO结算");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3("USD");
        A5.setA3Type("text");
        A5.setA4("LSMGO结算=还船时LSMGO1*LSMGO 单价 1+还船时LSMGO2*LSMGO 单价2");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part4");
        A6.setJsfhccbId(costId);
        A6.setA1("还船时VLSFO1");
        A6.setA1Type("text");
        A6.setA2Type("input");
        if(spFobSubleaseRedeliveryUpdate!=null){
            A6.setA2(spFobSubleaseRedeliveryUpdate.getVisfo());
        }
        A6.setA3("T");
        A6.setA3Type("text");
        A6.setA4("见还船通知");
        A6.setA4Type("text");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A6);

        SpFobJsfhccbItems A7 = new SpFobJsfhccbItems();
        A7.setTableId("Part4");
        A7.setJsfhccbId(costId);
        A7.setA1("还船时VLSFO2");
        A7.setA1Type("text");
        A7.setA2Type("input");
        A7.setA3("T");
        A7.setA3Type("text");
        //A7.setA4("见交船通知");
        A7.setA4Type("input");
        A7.setA5Type("upload");
        A7.setOrderNo(7);
        A7.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A7);

        SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
        A8.setTableId("Part4");
        A8.setJsfhccbId(costId);
        A8.setA1("还船VLSFO 单价 1");
        A8.setA1Type("text");
        A8.setA2Type("number");
        A8.setA3("USD");
        A8.setA3Type("text");
        // A8.setA4("VLSFO 部分 1=交船时VLSFO-还船时VLSFO");
        A8.setA4Type("input");
        A8.setA5Type("upload");
        A8.setOrderNo(8);
        A8.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A8);

        SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
        A9.setTableId("Part4");
        A9.setJsfhccbId(costId);
        A9.setA1("还船VLSFO 单价 2");
        A9.setA1Type("text");
        A9.setA2Type("number");
        A9.setA3("USD/T");
        A9.setA3Type("text");
        A9.setA4Type("input");
        A9.setA5Type("upload");
        A9.setOrderNo(9);
        A9.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A9);

        SpFobJsfhccbItems A10 = new SpFobJsfhccbItems();
        A10.setTableId("Part4");
        A10.setJsfhccbId(costId);
        A10.setA1("4.2VLSFO结算");
        A10.setA1Type("text");
        A10.setA2Type("number");
        A10.setA3("USD");
        A10.setA3Type("text");
        A10.setA4Type("text");
        A10.setA4("VLSFO结算=还船时VLSFO1*VLSFO单价 1+还船时VLSFO2*VLSFO单价2");
        A10.setA5Type("upload");
        A10.setOrderNo(10);
        A10.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A10);

        SpFobJsfhccbItems A11 = new SpFobJsfhccbItems();
        A11.setTableId("Part4");
        A11.setJsfhccbId(costId);
        A11.setA1("燃油部分结算");
        A11.setA1Type("text");
        A11.setA2Type("input");
        A11.setA3("USD");
        A11.setA3Type("text");
        A11.setA4Type("input");
        A11.setA4("燃油部分结算=4.1LSMGO结算+4.2 VLSFO结算");
        A11.setA5Type("upload");
        A11.setOrderNo(11);
        A11.setTableName("Part4（燃油费用=VLSFO费用+LSMGO费用）");
        tables1.add(A11);
        return tables1;
    }
    public List<SpFobJsfhccbItems> part855(Long costId,String processInstanceId,SpFobSublease execute,String key) {
        List<SpFobJsfhccbItems> tables1 = new ArrayList<>();
        // 第一个表格初始化
        SpFobJsfhccbItems A1 = new SpFobJsfhccbItems();
        A1.setTableId("Part5");
        A1.setJsfhccbId(costId);
        A1.setA1("还船LNG");
        A1.setA1Type("text");
        A1.setA2Type("input");
        SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);
        if(spFobSubleaseRedeliveryUpdate!=null){
            A1.setA2(spFobSubleaseRedeliveryUpdate.getLng());
        }
        A1.setA3Type("text");
        A1.setA3("m³");
        A1.setA4Type("input");
        A1.setA4("见还船通知");
        A1.setA5Type("upload");
        A1.setOrderNo(1);
        A1.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
        tables1.add(A1);

        SpFobJsfhccbItems A2 = new SpFobJsfhccbItems();
        A2.setTableId("Part5");
        A2.setJsfhccbId(costId);
        A2.setA1("还船Heel单价");
        A2.setA1Type("text");
        A2.setA2Type("number");
        A2.setA3Type("text");
        // A2.setA3("T");
        A2.setA4Type("input");
        //A2.setA4("见交船通知");
        A2.setA5Type("upload");
        A2.setOrderNo(2);
        A2.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
        tables1.add(A2);
        //SpFobSubleaseRedeliveryUpdate spFobSubleaseRedeliveryUpdate = spFobSubleaseRedeliveryUpdateService.findData(processInstanceId);

        SpFobJsfhccbItems A3 = new SpFobJsfhccbItems();
        A3.setTableId("Part5");
        A3.setJsfhccbId(costId);
        A3.setA1("还船FC热值系数");
        A3.setA1Type("text");
        A3.setA2Type("number");
        A3.setA3Type("text");
        // A3.setA3("T");
        A3.setA4Type("input");
        A3.setA4("");
        A3.setA5Type("upload");
        A3.setOrderNo(3);
        A3.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
        tables1.add(A3);
        SpFobJsfhccbItems A4 = new SpFobJsfhccbItems();
        A4.setTableId("Part5");
        A4.setJsfhccbId(costId);
        A4.setA1("还船时 LNG 总价");
        A4.setA1Type("text");
        A4.setA2Type("number");
        A4.setA3("USD");
        A4.setA3Type("input");
        A4.setA4("还船时LNG总价=还船LNG*还船Heel单价*还船FC热值系数");
        A4.setA4Type("input");
        A4.setA5Type("upload");
        A4.setOrderNo(4);
        A4.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
        tables1.add(A4);

        SpFobJsfhccbItems A5 = new SpFobJsfhccbItems();
        A5.setTableId("Part5");
        A5.setJsfhccbId(costId);
        A5.setA1("LNG底角结算");
        A5.setA1Type("text");
        A5.setA2Type("number");
        A5.setA3("USD");
        A5.setA3Type("text");
        A5.setA4("LNG底角结算=还船时LNG总价");
        A5.setA4Type("input");
        A5.setA5Type("upload");
        A5.setOrderNo(5);
        A5.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
        tables1.add(A5);

        SpFobJsfhccbItems A6 = new SpFobJsfhccbItems();
        A6.setTableId("Part5");
        A6.setJsfhccbId(costId);
        A6.setA1("自定义金额");
        A6.setA1Type("text");
        A6.setA2Type("number");
        A6.setA3("USD");
        A6.setA3Type("text");
        A6.setA4("");
        A6.setA4Type("input");
        A6.setA5Type("upload");
        A6.setOrderNo(6);
        A6.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
        tables1.add(A6);


        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getCurrency()!=null && conShipping.getCurrency()==3){
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part5");
            A8.setJsfhccbId(costId);
            A8.setA1("合计1");
            A8.setA1Type("text");
            A8.setA2Type("number");
            A8.setA3("EUR");
            A8.setA3Type("text");
            A8.setA4("合计 1=租金结算+还船费租金部分");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
            tables1.add(A8);
            SpFobJsfhccbItems A9 = new SpFobJsfhccbItems();
            A9.setTableId("Part5");
            A9.setJsfhccbId(costId);
            A9.setA1("合计2");
            A9.setA1Type("text");
            A9.setA2Type("number");
            A9.setA3("USD");
            A9.setA3Type("text");
            A9.setA4("合计 2= 还船费燃油部分-燃油结算-LNG 底角结算 ");
            A9.setA4Type("input");
            A9.setA5Type("upload");
            A9.setOrderNo(9);
            A9.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
            tables1.add(A9);
        }else {
            SpFobJsfhccbItems A8 = new SpFobJsfhccbItems();
            A8.setTableId("Part5");
            A8.setJsfhccbId(costId);
            A8.setA1("合计");
            A8.setA1Type("text");
            A8.setA2Type("number");
            A8.setA3("USD");
            A8.setA3Type("text");
            // A8.setA4("合计=租金结算+还船费结算+燃油结算+LNG 底角结算");
            A8.setA4Type("input");
            A8.setA5Type("upload");
            A8.setOrderNo(8);
            A8.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
            tables1.add(A8);
        }
        return tables1;
    }

    public Map<String,Object> valPartFob085(List<SpFobJsfhccbItems> list,String processInstanceId,String key){
        SpFobSublease execute =  spFobSubleaseService.getExceuteByInstanceId(processInstanceId);
        Map<String,Object> node = new HashMap<>();
        List<SpFobJsfhccbItems> tables1 = list.stream().filter(item->item.getTableId().equals("Part1")).collect(Collectors.toList());
        tables1 = bingTableUploadA5Record(tables1);
        List<SpFobJsfhccbItems> tables2 = list.stream().filter(item->item.getTableId().equals("Part2")).collect(Collectors.toList());
        tables2 = bingTableUploadA5Record(tables2);
        List<SpFobJsfhccbItems> tables3 = list.stream().filter(item->item.getTableId().equals("Part3")).collect(Collectors.toList());
        tables3 = bingTableUploadA5Record(tables3);
        List<SpFobJsfhccbItems> tables4 = list.stream().filter(item->item.getTableId().equals("Part4")).collect(Collectors.toList());
        tables4 = bingTableUploadA5Record(tables4);
        List<SpFobJsfhccbItems> tables5 = list.stream().filter(item->item.getTableId().equals("Part5")).collect(Collectors.toList());
        tables5 = bingTableUploadA5Record(tables5);

        List<BGTableDto> bgTableDtos = new ArrayList<>();
        BGTableDto dto = new BGTableDto();
        dto.setTableId("Part1");
        dto.setTableName("Part 1（运费=还船还船天数差×租金）");
        dto.setTables(tables1);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part2");
        dto.setTableName("Part 2（还船费租金部分）");
        dto.setTables(tables2);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part3");
        dto.setTableName("Part 3（还船费燃油部分）");
        dto.setTables(tables3);
        bgTableDtos.add(dto);

        dto = new BGTableDto();
        dto.setTableId("Part4");
        dto.setTableName("Part 4 （燃油费用=VLSFO费用+LSMGO费用）");
        dto.setTables(tables4);
        bgTableDtos.add(dto);
        dto = new BGTableDto();
        dto.setTableId("Part5");
        dto.setTableName("Part 5（LNG Heel结算=（还船Heel-还船Heel）*LNG价格");
        dto.setTables(tables5);
        bgTableDtos.add(dto);
        ConShipping conShipping = conShippingService.getById(execute.getConId());
        if(conShipping.getTradeBody()==1){
            node.put("currentTradeBody","国贸");
            node.put("upTradeBody","新贸");
        }else{
            node.put("currentTradeBody","新贸");
            node.put("upTradeBody","国贸");
        }
        node.put("tenant",conShipping.getTenant());
        node.put("shipowner",conShipping.getShipowner());
        node.put("shipName",execute.getShipName());
        node.put("data",bgTableDtos);
        return node;
    }


}
